Author rnk
Recipients benjamin.peterson, pitrou, rnk
Date 2009-11-25.02:21:15
SpamBayes Score 8.27037e-11
Marked as misclassified No
Message-id <1259115678.3.0.140520221277.issue6033@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2009-11-25 02:21:18rnksetrecipients: + rnk, pitrou, benjamin.peterson
2009-11-25 02:21:18rnksetmessageid: <1259115678.3.0.140520221277.issue6033@psf.upfronthosting.co.za>
2009-11-25 02:21:16rnklinkissue6033 messages
2009-11-25 02:21:15rnkcreate