PickleStorage

  • full name: tenpy.tools.cache.PickleStorage

  • parent module: tenpy.tools.cache

  • type: class

Inheritance Diagram

Inheritance diagram of tenpy.tools.cache.PickleStorage

Methods

PickleStorage.__init__(directory)

PickleStorage.close()

Close opened files, free memory and clean up temporary files/directories.

PickleStorage.delete(key)

Interface for cleaning up a previously saved data from disk in subclasses.

PickleStorage.load(key)

Interface for loading data from disk in subclasses.

PickleStorage.open([directory, tmpdir, delete])

Create a directory and use it to initialize a PickleCache.

PickleStorage.preload(key)

Interface for preloading data into the given dictionary into.

PickleStorage.save(key, value)

Interface for saving data to disk in subclasses.

PickleStorage.subcontainer(name)

Create another instance of the same class saving in a subdirectory/subgroup.

Class Attributes and Properties

PickleStorage.extension

filename extension

PickleStorage.trivial

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 with pickle.

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().

close()[source]

Close opened files, free memory and clean up temporary files/directories.

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.

load(key)[source]

Interface for loading data from disk in subclasses.

save(key, value)[source]

Interface for saving data to disk in subclasses.

delete(key)[source]

Interface for cleaning up a previously saved data from disk in subclasses.

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.