Q37: What are Weak References (weakref module) and when should they be used?
A weakref reference creates a pointer to an object without incrementing its reference count. Used to implement object caches or circular graphs without preventing Garbage Collector deallocation.
Key Takeaways
- References objects without incrementing reference counters.
- Prevents circular reference memory leaks in caches and graphs.
Knowledge Check
What is returned when attempting to access a weak reference whose underlying object was garbage collected?