pyphi.cache.content.ContentCache#

class pyphi.cache.content.ContentCache(name)[source]#

Bases: object

Parameters:

name (str)

property nbytes: int#

Estimated bytes held by this cache’s entries.

property evictions: int#

Entries discarded to stay within the byte bound.

observe(source, fingerprint)[source]#

Register source as a live carrier of fingerprint.

Parameters:
Return type:

None

get_or_compute(fingerprint, args, compute, *, store=True)[source]#

Return the cached value for (fingerprint, args), else compute it.

On a miss, compute is called and its result returned. An exception from compute propagates and no entry is added. The result is stored when store is true, evicting least recently used entries to stay within the cache’s byte bound once resident memory has reached the configured ceiling.

A hit reinserts its entry, which moves it to the recent end of the backing dict’s iteration order.

The hit path is lock-free; the hits and misses counters it updates are best-effort under free-threaded Python.

Parameters:
Return type:

Any