[Python-Dev] Why does getitem slot of builtin call sequence methods first? (original) (raw)
Michael Hudson mwh at python.net
Sun Oct 2 22:36:01 CEST 2005
- Previous message: [Python-Dev] Why does __getitem__ slot of builtin call sequence methods first?
- Next message: [Python-Dev] Why does __getitem__ slot of builtin call sequence methods first?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Travis Oliphant <oliphant at ee.byu.edu> writes:
Thanks for the tip. I think I figured out the problem, and it was my misunderstanding of how types inherit in C that was the source of my problem.
Basically, Python is doing what you would expect, the mpitem is used for getitem if both mpitem and sqitem are present. However, the addition of these descriptors (and therefore the resolution of any comptetion for getitem calls) is done before the inheritance of any slots takes place.
Oof. That'd do it.
The new ndarray object inherits from a "big" array object that doesn't define the sequence and buffer protocols (which have the size limiting int dependencing in their interfaces). The ndarray object has standard tpassequence and tpasbuffer slots filled.
I guess the reason this hasn't come up before is that non-trivial C inheritance is still pretty rare.
The easy fix was to initialize the tpasmapping slot before calling PyTypeReady. Hopefully, somebody else searching in the future for an answer to their problem will find this discussion useful.
Well, it sounds like a bug that should be easy to fix. I can't think of a reason to do slot wrapper generation before slot inheritance, though I wouldn't like to bet more than a beer on not having missed something...
Cheers, mwh
-- There are two kinds of large software systems: those that evolved from small systems and those that don't work. -- Seen on slashdot.org, then quoted by amk
- Previous message: [Python-Dev] Why does __getitem__ slot of builtin call sequence methods first?
- Next message: [Python-Dev] Why does __getitem__ slot of builtin call sequence methods first?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]