cfdm.persist_data¶
- cfdm.persist_data(*arg)[source]¶
Control the persistence of computed data.
If True then a computed
cfdm.Datainstance will cache the entire computed array (in chunks) in memory, ready for fast future access. If False then computed data is not cached.This behaviour may be overridden on an individual basis by the persist parameter of the
cfdm.Data.computemethod.Added in version (cfdm): 1.13.1.0
See also
- Parameters:
- Returns:
ConstantThe value prior to the change, or the current value if no new value was specified.
Examples
>>> cfdm.persist_data() <Constant: False> >>> print(cfdm.persist_data()) False >>> bool(cfdm.persist_data()) False >>> cfdm.persist_data().value False
>>> old = cfdm.persist_data(True) >>> cfdm.persist_data() <Constant: True> >>> cfdm.persist_data(old) <Constant: False> >>> cfdm.persist_data() <Constant: False>
Use as a context manager:
>>> print(cfdm.persist_data()) False >>> with cfdm.persist_data(True): ... print(cfdm.persist_data()) ... True >>> print(cfdm.persist_data()) False