[Python-Dev] PEP 447 (type.__getdescriptor__)
Ronald Oussoren
ronaldoussoren at mac.com
Wed Jul 22 19:21:06 CEST 2015
> On 22 Jul 2015, at 18:02, Terry Reedy <tjreedy at udel.edu> wrote:
>
> On 7/22/2015 3:25 AM, Ronald Oussoren wrote:
>> Hi,
>>
>> Another summer with another EuroPython, which means its time again to
>> try to revive PEP 447…
>>
>> I’ve just pushes a minor update to the PEP and would like to get some
>> feedback on this, arguably fairly esoteric, PEP.
>
> Yeh, a bit too esoteric for most of us to review.
I noticed that in my previous attempts as well. There is only a limited number of people the really grok how Python’s attribute lookup works, and a smaller subset of those understand how that’s implemented in CPython.
> For instance, it is not obvious to me, not familiar with internal details, after reading the intro, why a custom __getattribute__ is not enough and why __getdescriptor__ would be needed.
That means the PEP text needs some more work. Using __getattribute__ works for normal attribute access, but not when you look for a superclass implementation using super() because super currently *only* looks in the __dict__ of classes further along the MRO and offers no way to influence the search. That’s a problem when classes can grow methods dynamically.
> If Guido does not want to review this, you need to find a PEP BDFL for this.
I’ll see if I can corner him at EP :-). Its surprisingly hard to find people at conferences.
>
> There are two fairly obvious non-esoteric questions:
>
> 1. How does this impact speed (updated section needed)?
The speed impact should be minimal, the initial version of the patch (which needs some updating which I’ll try to do during the EP sprints) uses shortcuts to avoid actually calling the __getdescriptor__ method in the usual case.
>
> 2. Is this useful, that you can think of, for anything other than connecting to Objective C?
Not immediately. But then again, I initially thought that decorators would have limited appeal as well :-). I guess this could be useful for other proxy-like objects as well, especially when preloading the __dict__ is relatively expensive.
Apart from direct usefulness this closes a hole in the way you can influence attribute lookup.
Ronald
>
> --
> Terry Jan Reedy
>
>
> _______________________________________________
> Python-Dev mailing list
> Python-Dev at python.org
> https://mail.python.org/mailman/listinfo/python-dev
> Unsubscribe: https://mail.python.org/mailman/options/python-dev/ronaldoussoren%40mac.com
More information about the Python-Dev
mailing list