> > > Good point. Plain old types currently (in the descr-branch) have a > > > readonly dict (using a proxy) and no settable attributes. I will > > > probably give types settable attributes in a next revision, but I > > > prefer not to make the type's dict writable -- I need to be able to > > > watch the setattr calls so that if someone changes > > > DictType.__getitem__ I can change the mp_subscript to a C function > > > that calls the __getitem__ method. Alas, I think I'll have to withdraw this promise for now. The truly built-in types are static objects that are shared between all interpreter instances within one process, and each type has only one dictionary pointer. So changes to the __dict__ would affect other interpreter instances, and that's unacceptable. I've thought about alternatives; I can't give each interpreter its own set of types because sometimes objects are shared between interpreters (e.g. the dictionary of interned strings), and then then their types have to be shared too! Not having any object sharing would mean too much of a change to the foundations of the implementation. I think we'll have to live with this restriction until Python 3000. Personally, I don't mind -- I see mostly possible abuses for the ability to change attributes of e.g. DictType or StringType. :-) --Guido van Rossum (home page: http://www.python.org/~guido/)
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