[Pyrex] pyrex functions to replace a method (Re: replace a method in class: how?)

Greg Ewing greg.ewing at canterbury.ac.nz
Tue Jun 27 23:56:55 UTC 2006


Brian Blais wrote:
> I have found a very similar problem trying to replace a method using a 
> function defined in pyrex.

Functions defined in Pyrex are C-implemented functions,
which don't trigger the method binding magic when you
access them through a class. The same thing happens if
you try to use a built-in function as a method.

What *should* work is to define the method inside a
class in Pyrex (plain class, not extension type) and
extract it out of the class's __dict__. That's because
Pyrex pre-wraps a function defined in a class in an
unbound method object before putting it in the class.

I have suggested that builtin functions should be
given the same method-binding behaviour as interpreted
functions. The idea wasn't rejected out of hand, but
I don't think anything has been done about it yet.

--
Greg



More information about the Pyrex mailing list