PickleStorage
full name: tenpy.tools.cache.PickleStorage
parent module:
tenpy.tools.cache
type: class
Inheritance Diagram
Methods
|
|
Close opened files, free memory and clean up temporary files/directories. |
|
|
Interface for cleaning up a previously saved data from disk in subclasses. |
|
Interface for loading data from disk in subclasses. |
|
Create a directory and use it to initialize a |
Interface for preloading data into the given dictionary into. |
|
|
Interface for saving data to disk in subclasses. |
Create another instance of the same class saving in a subdirectory/subgroup. |
Class Attributes and Properties
filename extension |
|
Whether the storage is actually kept in memory, instead of saving to disk. |
- class tenpy.tools.cache.PickleStorage(directory)[source]
Bases:
Storage
Subclass of
Storage
which saves long-term data on disk withpickle
.- Parameters:
directory (path-like) – An existing directory within which pickle files will be saved for each key.
- trivial = False
Whether the storage is actually kept in memory, instead of saving to disk.
- extension = '.pkl'
filename extension
- classmethod open(directory=None, tmpdir=None, delete=True)[source]
Create a directory and use it to initialize a
PickleCache
.- Parameters:
directory (path-like | None) – Name of a directory to be created, in which pickle files will be stored. If None, create a temporary directory with
tempfile
tools.tmpdir (path-like | None) – Only used if directory is None. Used as base dir for
tempfile.mkdtemp()
, i.e., a temporary directory is created within this path.delete (bool) – Whether to automatically remove the directory in
close()
.
- subcontainer(name)[source]
Create another instance of the same class saving in a subdirectory/subgroup.
This method allows multiple
DictCache
instance re-using open resources. Subcontainers will explicitly be closed when any of the parent containers (on which subcontainer() was called) is closed.
- preload(key)[source]
Interface for preloading data into the given dictionary into.
Only overridden in
ThreadedStorage
for thread-parallelized pre-loading; in other cases it does nothing.