[issue6033] LOOKUP_METHOD and CALL_METHOD optimization
Reid Kleckner
report at bugs.python.org
Wed Nov 25 03:21:18 CET 2009
Reid Kleckner <rnk at mit.edu> added the comment:
One thing I was wondering about the current patch is what about objects
that have attributes that shadow methods? For example:
class C(object):
def foo(self):
return 1
c = c()
print c.foo()
c.foo = lambda: 2
print c.foo()
Shouldn't the above print 1 and 2? With the current patch, it seems
that you might still print 1.
There's also the possible performance drawback where you're loading
builtin C methods, so the optimization fails, but you end up calling
_PyType_Lookup twice. :(
I'm doing the same optimization for unladen swallow, and these were some
of the things I ran into. I think I'm going to write a
PyObject_GetMethod that tries to get a method without binding it, but if
it can't for any reason, it behaves just like PyObject_GetAttr and sets
a status code.
----------
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue6033>
_______________________________________
More information about the Python-bugs-list
mailing list