
Here are my real-world use cases. Not for security, but for safety and performance reasons (I've built by own RODict and ROList modeled after dictproxy):
- Global, but immutable containers, e.g. as class members
I attached type_final.patch to the issue #14162 to demonstrate how frozendict can be used to implement a "read-only" type. Last version: http://bugs.python.org/file24696/type_final.patch
Oh, hmm. I rather meant something like that:
""" class Foo: some_mapping = frozendict( blah=1, blub=2 ) or as a variant:
def zonk(some_default=frozendict(...)): ... or simply a global object:
baz = frozendict(some_immutable_mapping) """
Ah yes, frozendict is useful for such cases.
I'm not sure about your final types. I'm using __slots__ = () for such things
You can still replace an attribute value if a class defines __slots__:
class A: ... __slots__=('x',) ... x = 1 ... A.x=2 A.x 2
Victor