TempMemoryContext

Qualified name: algan.utils.memory\_utils.TempMemoryContext

class TempMemoryContext(memory, clear_persist, persist_floor=None)[source]

Bases: object

Restore the arena pointers on exit.

clear_persist additionally rewinds the persistent (reverse) pointer to its value at entry. persist_floor is a zero-argument callable returning a reverse pointer that rewind must not cross, or None – for the caller that allocates something batch-lived at the persistent end from inside the scope and needs it readable after the scope closes. It is read on exit, not on entry, because that allocation happens during the block. Explicit rather than inferred from the arena, so an unrelated persistent allocation inside the scope is still reclaimed.

Methods