What stimulated this thread about making mutable objects (temporarily) immutable? Can someone give me an example where this is actually useful and can't be handled through some existing mechanism? I'm definitely with Fredrik on this one. Sounds like madness to me. I'm just guessing here, but since the most common need for immutable objects is a dictionary keys, I can envision having to test the lock state of a list or dict that someone wants to use as a key everywhere you would normally call has_key: if l.islocked() and d.has_key(l): ... If you want immutable dicts or lists in order to use them as dictionary keys, just serialize them first: survey_says = {"spam": 14, "eggs": 42} sl = marshal.dumps(survey_says) dict[sl] = "spam" Here's another pitfall I can envision. survey_says = {"spam": 14, "eggs": 42} survey_says.lock() dict[survey_says] = "Richard Dawson" survey_says.unlock() At this point can I safely iterate over the keys in the dictionary or not? Skip
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4