Numba caching tools#

Classes:

HashCacheLocator(py_func, py_file)

Cache with file hash

SharedHashCacheLocator(py_func, py_file)

Cache with file hash in (more) shareable location.

class cmomy.cache.HashCacheLocator(py_func, py_file)[source]#

Bases: UserProvidedCacheLocator

Cache with file hash

Use this with NUMBA_CACHE_DIR and NUMBA_CACHE_LOCATOR_CLASS="cmomy.cache.HashCacheLocator". Cache location is identical to default, but with cache key (NUMBA_CACHE_TOOLS_MAGIC, file-hash) where file-hash is the sha256 of the file.

Methods:

get_source_stamp()

Get a timestamp representing the source code's freshness.

get_source_stamp()[source]#

Get a timestamp representing the source code’s freshness. Can return any picklable Python object.

class cmomy.cache.SharedHashCacheLocator(py_func, py_file)[source]#

Bases: HashCacheLocator

Cache with file hash in (more) shareable location.

Like HashCacheLocator, but location is calculated as NUMBA_CACHE_DIR / directory-magic-package-package_version-system where system is a combination of the numba version, python version, platform, and machine.

Methods:

get_suitable_cache_subpath(py_file)

Given the Python file path, compute a suitable path inside the cache directory.

classmethod get_suitable_cache_subpath(py_file)[source]#

Given the Python file path, compute a suitable path inside the cache directory.

This will reduce a file path that is too long, which can be a problem on some operating system (i.e. Windows 7).