Re: [Python-Dev] Hooking into super() attribute resolution

2013-07-09 Thread Ronald Oussoren

On 9 Jul, 2013, at 1:21, Steve Dower  wrote:
>> 
> 
> Except that if it's on a metaclass, the 'instance' it has access to is cls. 
> The descriptor side of things is more interesting, but I see no reason why 
> super can't do that itself, since it knows the actual instance to call 
> __get__ with. (Presumably it already does this with the __dict__ lookup, 
> since that won't call __get__ either.)
> 
> Explaining the new method is easiest if the default implementation is 
> (literally):
> 
> def __getlocalname__(self, name):
>try:
>return self.__dict__[name]
>except KeyError:
>raise AttributeError(name)
> 
> which does not do any descriptor resolution (and is only a small step from 
> simply replacing __dict__ with a custom object, which is basically where we 
> started). The only change I've really suggested is making it an instance 
> method that can be implemented on a metaclass if you want it for class 
> members.

I like this idea and will experiment with implementing this later this week.  
The only thing I'm not sure about is how to indicate that the name could not be 
found, raising an exception could end up being to expensive if the 
__getlocalname__ hook gets used in object.__getattribute__ as well. I guess 
I'll have to run benchmarks to determine if this really is a problem.

Ronald
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Accepting PEP 445

2013-07-09 Thread Martin v. Löwis
Am 07.07.13 01:04, schrieb Victor Stinner:
> 2013/7/6 Antonio Cavallo :
>> Could that remove the need for the --with-pydebug flag?
> 
> With the PEP 445, you still have to recompile Python with
> --with-debug, but you don't have to recompile Python extensions
> anymore. 

Really? What about _PyObject_HEAD_EXTRA? The object layout
still changes under --with-pydebug, AFAICT.

Regards,
Martin


___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com