<method-wrapper>.__self__

  • Thread starter Hallvard B Furuseth
  • Start date
H

Hallvard B Furuseth

What's the difference between a built-in method and a method-wrapper
object? Why has only the former a __self__, even though both are
tied to the object on which to perform the operation?
Why do list.pop and list.__len__ have different types at all?
[5].pop.__self__ [5]
[5].__len__.__self__
Traceback (most recent call last):
<slot wrapper '__len__' of 'list' objects>
 
M

Michael Hudson

Hallvard B Furuseth said:
What's the difference between a built-in method and a method-wrapper
object?

I *think* method-wrapper's are wrappers around type methods, aka
tp_wotsit slots at the C level. builtin-methods are, well, builtin
methods, similar to method's on regular Python classes but implemented
in C.
Why has only the former a __self__, even though both are tied to the
object on which to perform the operation?

Because.

Probably an oversight.
Why do list.pop and list.__len__ have different types at all?

Well, because they do :) See above.

If you want to really dig into this sort of thing, you're going to
need to read some source.

Cheers,
mwh
 
H

Hallvard B Furuseth

Michael said:
I *think* method-wrapper's are wrappers around type methods, aka
tp_wotsit slots at the C level. builtin-methods are, well, builtin
methods, similar to method's on regular Python classes but implemented
in C.
(...)
If you want to really dig into this sort of thing, you're going to
need to read some source.

Thanks.
I think I'll file it as a doc bug instead. Someone else can decide if
it's more than that:)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,202
Messages
2,571,057
Members
47,665
Latest member
salkete

Latest Threads

Top