omnipy.util.weak
Weak-reference containers keyed by object identity.
This module provides helpers for storing values against live objects without keeping those keys alive, while still performing lookups by object identity.
| CLASS | DESCRIPTION |
|---|---|
KeyRef |
Identity-based weak-dictionary key wrapper. |
WeakKeyRefContainer |
Map live objects to values without keeping the keys alive. |
KeyRef
Bases: list
flowchart BT
omnipy.util.weak.KeyRef[KeyRef]
click omnipy.util.weak.KeyRef href "" "omnipy.util.weak.KeyRef"
Identity-based weak-dictionary key wrapper.
| PARAMETER | DESCRIPTION |
|---|---|
obj
|
Object whose identity should be used as the key value.
TYPE:
|
| METHOD | DESCRIPTION |
|---|---|
__init__ |
|
Source code in src/omnipy/util/weak.py
WeakKeyRefContainer
Bases: Generic[_AnyKeyT, _ValT]
flowchart BT
omnipy.util.weak.WeakKeyRefContainer[WeakKeyRefContainer]
click omnipy.util.weak.WeakKeyRefContainer href "" "omnipy.util.weak.WeakKeyRefContainer"
Map live objects to values without keeping the keys alive.
The container stores a weak reference to each original key object and uses a stable identity wrapper so callers can retrieve values with the original object instance while automatic cleanup still works when keys are collected.
-
Reference
Code reference
omnipy
data
snapshotSnapshotHolder
| METHOD | DESCRIPTION |
|---|---|
__init__ |
|
clear |
Remove all key and value references from the container. |
get |
Return the value associated with a live key object. |
Source code in src/omnipy/util/weak.py
__init__
clear
get
Return the value associated with a live key object.
| PARAMETER | DESCRIPTION |
|---|---|
key
|
Key object to look up by identity.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
_ValT | None
|
The stored value for the key, or |