<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On 26 Jul 2015, at 09:14, Ronald Oussoren <<a href="mailto:ronaldoussoren@mac.com" class="">ronaldoussoren@mac.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div class=""><blockquote type="cite" class=""><div class="">On 25 Jul 2015, at 17:39, Mark Shannon <<a href="mailto:mark@hotpy.org" class="">mark@hotpy.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class="">Hi,<br class=""><br class="">On 22/07/15 09:25, Ronald Oussoren wrote:> Hi,<br class=""><blockquote type="cite" class=""><br class="">Another summer with another EuroPython, which means its time again to <br class="">try to revive PEP 447…<br class=""><br class=""></blockquote><br class="">IMO, there are two main issues with the PEP and implementation.<br class=""><br class="">1. The implementation as outlined in the PEP is infinitely recursive, since the<br class="">lookup of "__getdescriptor__" on type must necessarily call<br class="">type.__getdescriptor__.<br class="">The implementation (in C) special cases classes that inherit "__getdescriptor__"<br class="">from type. This special casing should be mentioned in the PEP.<br class=""></div></blockquote><div class=""><br class=""></div>Sure.  An alternative is to slightly change the the PEP: use __getdescriptor__ when</div><div class="">present and directly peek into __dict__ when it is not, and then remove the default</div><div class="">__getdescriptor__. </div><div class=""><br class=""></div><div class="">The reason I didn’t do this in the PEP is that I prefer a programming model where</div><div class="">I can explicitly call the default behaviour. </div></div></div></blockquote><br class=""></div><div>I’m not sure there is a problem after all (but am willing to use the alternative I describe above),</div><div>although that might be because I’m too much focussed on CPython semantics.</div><div><br class=""></div><div>The __getdescriptor__ method is a slot in the type object and because of that the</div><div> normal attribute lookup mechanism is side-stepped for methods implemented in C. A</div><div>__getdescriptor__ that is implemented on Python is looked up the normal way by the </div><div>C function that gets added to the type struct for such methods, but that’s not a problem for</div><div>type itself.</div><div><br class=""></div><div>That’s not new for __getdescriptor__ but happens for most other special methods as well,</div><div>as I noted in my previous mail, and also happens for the __dict__ lookup that’s currently</div><div>used (t.__dict__ is an attribute and should be lookup up using __getattribute__, …)</div><div><br class=""></div><div>Ronald</div></body></html>