On Nov 26, 2007 2:53 PM, Nick Coghlan <[EMAIL PROTECTED]> wrote:
> Christian Heimes wrote:
> > Greg Ewing wrote:
> >> This needs consideration. Pyrex currently makes use of
> >> this behaviour when defining a Python class having Pyrex
> >> functions as methods.
> >>
> >> However, a better solution for Pyrex would be to add
> >> method-binding behaviour to the C function object, so
> >> that C functions can be used directly as methods. The
> >> above example would then work simply by doing
> >>
> >>    Example.id = id
> >
> > A C function binder is very easy to implement.
>
> True, but it would probably make more sense to find a way to let Pyrex
> re-use the method descriptor already used for builtin types:
>
>  >>> type(str.lower)
> <type 'method_descriptor'>
>
> Interestly, I just discovered that method descriptors for builtins don't
> define im_class, im_self or im_func. I never knew that - I thought they
> had the same interface as instance methods.

They have, if you only consider the *important* operations. For method
descriptors the only thing you can count on is __call__. The rest are
internal implementation details -- and besides, what would you expect
im_func to be for a C function? :-)

-- 
--Guido van Rossum (home page: http://www.python.org/~guido/)
_______________________________________________
Python-3000 mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-3000
Unsubscribe: 
http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com

Reply via email to