[pypy-dev] Unbound method must be called with instance as first argument

Armin Rigo arigo at tunes.org
Wed Jul 7 15:26:03 CEST 2004

Hello Richard,

On Tue, Jul 06, 2004 at 02:12:04PM +0100, Richard Emslie wrote:
> >>The CPython implementation seems to be doing some hairy caching instead of
> >>creating new method each __get__(), so it hard to tell if this is correct
> >>behaviour.

I believe we should closely follow CPython's behavior unless there is a reason 
not to.  The algorithm appears to look like:

* already bound methods are never re-bound

* unbound method objects can get bound but only to something more specific 
than before.  For example if you do:

class C: pass
class D: pass   # not a subclass
C.m = ...
D.m = C.m

then D().m doesn't give you a bound method in CPython either.  I'm not sure 
why exactly it is so, but I guess it makes some sense.

Also note that in your patch you shouldn't assume that w_function is a wrapped
Function instance (the name is bad, it should be w_callable).

A bientot,


More information about the Pypy-dev mailing list