Lazy-Freeze: A New Look at Hashing and Immutability
summary
Lazy-Freeze makes objects start mutable and automatically become immutable when __hash__ runs, implemented as a class decorator that wraps __hash__, __setattr__, __delattr__ and in‑place ops; a demo fixes a corrupted LRU cache by raising an exception when mutation follows hashing. It captures the calling stack with an optional debug stack trace and limits protection to chosen attributes with a frozen_attrs option. A lock argument serializes hashtaken checks for thread safety; code is packaged and shown working in live examples.
AI-written summary · about
