Python: store extra data for objects in a WeakKeyDictionary
When you need extra data associated with objects without preventing garbage collection, WeakKeyDictionary gives you a safe mapping from object to metadata. It’s a practical fit for cases like Django tooling that tracks state per AST nodes, such as django-upgrade’s fixer functions.