[Python-3000] Unbound methods -- keep creating API?

Guido van Rossum guido at python.org
Mon Nov 26 03:54:55 CET 2007


On Nov 25, 2007 2:39 PM, Christian Heimes <lists at cheimes.de> 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
>
> Why was the builtin_function_or_method type introduced and what's the
> rational of the different behavior? Maybe we could add an API to wrap a
> CFunction in an ordinary function?

And how would that work? Ultimately, a CFunction wraps a C function
pointer, while a Python function wraps a (byte)code object. Totally
different functionality inside. Anyway, even if you have a way around
that, this answers your "why" question. I see no reason why all
functions should be instances of the same type -- after all, we do
duck typing, right? :-)

-- 
--Guido van Rossum (home page: http://www.python.org/~guido/)


More information about the Python-3000 mailing list