[Python-Dev] PEP 362 implementation issue: C callables

Daniel Urban urban.dani+py at gmail.com
Sat Jun 16 12:21:34 CEST 2012


On Fri, Jun 15, 2012 at 11:24 PM, Larry Hastings <larry at hastings.org> wrote:
> There are four more candidates I found with the grep but couldn't figure out
> how to instantiate and test.  They have to do with the descriptor protocol,
> aka properties, but the types aren't directly exposed by Python.  They're
> all defined in Object/descrobject.c.  The internal class names are:
>
> method_descriptor
> classmethod_descriptor
> wrapper_descriptor
> method-wrapper (you get one of these out of a "wrapper_descriptor")

'method_descriptor' is apparently used for the methods of built-in
(implemented in C) objects:
>>> set.__dict__['union'].__class__
<class 'method_descriptor'>

'classmethod_descriptor' is similarly for the classmethods of built-in classes:
>>> import itertools
>>> itertools.chain.__dict__['from_iterable'].__class__
<class 'classmethod_descriptor'>

'wrapper_descriptor' is used for example the operators of built-in types:
>>> int.__dict__['__add__'].__class__
<class 'wrapper_descriptor'>

And 'method-wrapper':
>>> (5).__add__.__class__
<class 'method-wrapper'>


Daniel


More information about the Python-Dev mailing list