-
Notifications
You must be signed in to change notification settings - Fork 52
Open
Description
>>> type(int.__add__)
<class 'wrapper_descriptor'>
>>> type((0).__add__)
<class 'method-wrapper'>
Compare to
>>> type(int.bit_count)
<class 'method_descriptor'>
>>> type((0).bit_count)
<class 'builtin_function_or_method'>
Wrapper descriptors and method wrappers are artifacts of the implementation. Ideally they would not exist and we would get
>>> type(int.__add__)
<class 'method_descriptor'>
>>> type((0).__add__)
<class 'builtin_function_or_method'>
We would like these wrapper descriptors to be method descriptors in order to simplify optimization and generally reduce the number of special cases.
There are two obstacles to doing this.
- These two types are exposed in the
types
module, so we cannot remove them altogether. Maybe we could maketypes.WrapperDescriptorType
a subclass of method descriptor to simplify things, or just maketypes.WrapperDescriptorType
an alias? - There is no way to efficiently wrap a binary C function in a method descriptor. This is easily fixed by adding a
METH_OO
flag for functions taking two arguments enabling effective specialization of these functions
dg-pb
Metadata
Metadata
Assignees
Labels
No labels