File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -138,6 +138,30 @@ p_raw = ptr(MemoryResolver(memory, 0)) # no wrapper
138138p2 = p_raw + 4 # advances by 4 bytes
139139```
140140
141+ ## Caching
142+
143+ Pointer dereferencing is cached — repeated calls to ` unwrap() ` or ` try_unwrap() ` return the same object without re-inflating:
144+
145+ ``` python
146+ r1 = node.next.unwrap()
147+ r2 = node.next.unwrap()
148+ assert r1 is r2 # same object
149+ ```
150+
151+ If the underlying memory changes, call ` invalidate() ` to clear the cache:
152+
153+ ``` python
154+ # Memory was modified externally
155+ node.next.invalidate()
156+ r3 = node.next.unwrap() # re-inflated from updated memory
157+ ```
158+
159+ Setting the pointer's value automatically invalidates the cache:
160+
161+ ``` python
162+ node.next.value = new_address # cache cleared automatically
163+ ```
164+
141165## Pointer String Representation
142166
143167``` python
Original file line number Diff line number Diff line change 6565 - Freeze, Diff & Reset : advanced/freeze_diff.md
6666 - C Struct Parser : advanced/c_parser.md
6767 - Forward References : advanced/forward_refs.md
68+ - Hex Dump : advanced/hexdump.md
6869 - Field Offsets : advanced/offset.md
You can’t perform that action at this time.
0 commit comments