Re: [Python-Dev] [Python-3000] PEP 367: New Super
Tim Delaney wrote:
Phillip J. Eby wrote:
At 05:23 PM 5/14/2007 +1000, Tim Delaney wrote:
Determining the class object to use '''''''''''''''''''''''''''''''''''
The exact mechanism for associating the method with the defining class is not specified in this PEP, and should be chosen for maximum performance. For CPython, it is suggested that the class instance be held in a C-level variable on the function object which is bound to one of ``NULL`` (not part of a class), ``Py_None`` (static method) or a class object (instance or class method).
Another open issue here: is the decorated class used, or the undecorated class?
Sorry I've taken so long to get back to you about this - had email problems. I'm not sure what you're getting at here - are you referring to the decorators for classes PEP? In that case, the decorator is applied after the class is constructed, so it would be the undecorated class.
Are class decorators going to update the MRO? I see nothing about that in PEP 3129, so using the undecorated class would match the current super(cls, self) behaviour.
Duh - I'm an idiot. Of course, the current behaviour uses name lookup, so it would use the decorated class. So the question is, should the method store the class, or the name? Looking up by name could pick up a totally unrelated class, but storing the undecorated class could miss something important in the decoration. Tim Delaney
Tim Delaney wrote:
So the question is, should the method store the class, or the name? Looking up by name could pick up a totally unrelated class, but storing the undecorated class could miss something important in the decoration.
Couldn't we provide a mechanism whereby the cell can be adjusted to point to the decorated class? (heck, the interpreter has access to both classes after execution of the class statement - it could probably arrange for this to happen automatically whenever the decorated and undecorated classes are different). Cheers, Nick. -- Nick Coghlan | ncoghlan@gmail.com | Brisbane, Australia --------------------------------------------------------------- http://www.boredomandlaziness.org
Nick Coghlan wrote:
Tim Delaney wrote:
So the question is, should the method store the class, or the name? Looking up by name could pick up a totally unrelated class, but storing the undecorated class could miss something important in the decoration.
Couldn't we provide a mechanism whereby the cell can be adjusted to point to the decorated class? (heck, the interpreter has access to both classes after execution of the class statement - it could probably arrange for this to happen automatically whenever the decorated and undecorated classes are different).
Yep - I thought of that. I think that's probably the right way to go. Tim Delaney
At 06:20 PM 5/20/2007 +1000, Tim Delaney wrote:
Nick Coghlan wrote:
Tim Delaney wrote:
So the question is, should the method store the class, or the name? Looking up by name could pick up a totally unrelated class, but storing the undecorated class could miss something important in the decoration.
Couldn't we provide a mechanism whereby the cell can be adjusted to point to the decorated class? (heck, the interpreter has access to both classes after execution of the class statement - it could probably arrange for this to happen automatically whenever the decorated and undecorated classes are different).
Yep - I thought of that. I think that's probably the right way to go.
Btw, PEP 3124 needs a way to receive the same class object at more or less the same moment, although in the form of a callback rather than a cell assignment. Guido suggested I co-ordinate with you to design a mechanism for this.
participants (3)
-
Nick Coghlan
-
Phillip J. Eby
-
Tim Delaney