[Python-Dev] special method lookup: how much do we care?
Terry Reedy
tjreedy at udel.edu
Sat May 9 00:41:14 CEST 2009
Benjamin Peterson wrote:
> A while ago, Guido declared that all special method lookups on
> new-style classes bypass __getattr__ and __getattribute__. This almost
> completely consistent now, and I've been working on patching up a few
> incorrect cases. I've know hit __enter__ and __exit__. The compiler
> generates LOAD_ATTR instructions for these, so it uses the normal
> lookup. The only way I can see to fix this is add a new opcode which
> uses _PyObject_LookupSpecial, but I don't think we really care this
> much. Opinions?
1.More consistent attribute lookup is, to me, a feature of 3.x and I
appreciate you working on this.
2. I am puzzled why those two methods should be extra special, but don't
know enough to say more.
3. If there are only those two or a couple of other exceptions, I'd like
them listed in the 'Special method lookup' ref doc section.
tjr
More information about the Python-Dev
mailing list