2009/5/8 Daniel Stutzbach <dan...@stutzbachenterprises.com>: > On Fri, May 8, 2009 at 1:09 PM, Benjamin Peterson <benja...@python.org> > wrote: >> >> 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? > > Why does this problem arise only with __enter__ and __exit__?
Normally special methods use slots of the PyTypeObject struct. typeobject.c looks up all those methods on Python classes correctly. In the case of __enter__ and __exit__, the compiler generates bytecode to look them up, and that bytecode use PyObject_Getattr. -- Regards, Benjamin _______________________________________________ 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