Dirty Tracking API
DirtyTimestampProvider
Bases: Protocol
Protocol for anything that tracks a modification time.
Source code in src/packed_data_structures/arrays/dirty_tracking.py
DirtyTrackingArray
Bases: ndarray, DirtyTimestampProvider
A numpy array that updates a shared timestamp on every modification.
This class auto-updates a shared timestamp reference whenever contents are modified via setitem or in-place ufuncs.
Source code in src/packed_data_structures/arrays/dirty_tracking.py
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 | |
__array_ufunc__
Delegate ufuncs while preserving timestamp semantics.
- If outputs include any DirtyTrackingArray, update their timestamp.
- Allow broadcasts into DirtyTrackingArray outputs by coercing outputs to base ndarrays for the op, then wrapping/updating tracking after.
Source code in src/packed_data_structures/arrays/dirty_tracking.py
__new__
__new__(
input_array: ndarray[T_s, dtype[T_dt]],
timestamp_ref: TimestampRef | None = None,
) -> DirtyTrackingArray[T_s, T_dt]
Creates a new DirtyTrackingArray instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input_array
|
ndarray[T_s, dtype[T_dt]]
|
The input array to wrap or cast. |
required |
timestamp_ref
|
TimestampRef | None
|
Optional, pre-existing TimestampRef object. |
None
|
Source code in src/packed_data_structures/arrays/dirty_tracking.py
ProvidesDirtyTimestamp
Bases: ABC
Mixin that aggregates multiple dirty timestamp sources via caching.
Subclasses must implement _collect_dirty_sources.
Subclasses should call _invalidate_dirty_cache when their structure changes.
Source code in src/packed_data_structures/arrays/dirty_tracking.py
tracked_njit
Wraps a Numba function to automatically update timestamps of modified arrays.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mutates
|
Callable[..., Sequence[Any]]
|
A function (or lambda) that accepts the same arguments as the decorated function and returns a sequence of arrays that are predicted to be modified. |
required |
**njit_kwargs
|
Any
|
Arguments passed directly to nb.njit (e.g., cache=True). |
{}
|