[Python-Dev] PEP 487: Simpler customization of class creation (original) (raw)
Eric Snow ericsnowcurrently at gmail.com
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 tpdict 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.newclass (universal) - calling type() directly (universal) - PyTypeReady (CPython-specific) - PyTypeFromSpec (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 tpdict or a new definitionorder 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 ]