[Python-Dev] PEP 487: Simpler customization of class creation
Eric Snow
ericsnowcurrently at gmail.com
Tue Jun 21 20:50:19 EDT 2016
More information about the Python-Dev mailing list
Tue Jun 21 20:50:19 EDT 2016
- Previous message (by thread): [Python-Dev] PEP 487: Simpler customization of class creation
- Next message (by thread): [Python-Dev] PEP 487: Simpler customization of class creation
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Tue, Jun 21, 2016 at 3:01 PM, Nick Coghlan <ncoghlan at gmail.com> wrote: > RIght, if *tp_dict itself* on type objects is guaranteed to be > order-preserviing, then we don't need to do anything except perhaps > provide a helper method or descriptor on type that automatically > filters out the dunder-attributes, and spell out the type dict > population order for: > > - class statements (universal) > - types.new_class (universal) > - calling type() directly (universal) > - PyType_Ready (CPython-specific) > - PyType_FromSpec (CPython-specific) The problem I have with this is that it still doesn't give any strong relationship with the class definition. Certainly in most cases it will amount to the same thing. However, there is no way to know if cls.__dict__ represents the class definition or not. You also lose knowing whether or not a class came from a definition (or acts as though it did). Finally, __definition_order__ makes the relationship with the definition order clear, whereas cls.__dict__ does not. Instead of being an obvious tool, with cls.__dict__ that relationship would be tucked away where only a few folks with deep knowledge of Python would be in a position to take advantage. > > Something that isn't currently defined in PEP 520, and probably should > be regardless of whether the final implementation is an order > preserving tp_dict or a new __definition_order__ attribute, is where > descriptors implicitly defined via __slots__ will appear relative to > other attributes. I'll add that. -eric
- Previous message (by thread): [Python-Dev] PEP 487: Simpler customization of class creation
- Next message (by thread): [Python-Dev] PEP 487: Simpler customization of class creation
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-Dev mailing list