[Python-Dev] Why does getitem slot of builtin call sequence methods first? (original) (raw)
Guido van Rossum guido at python.org
Sun Oct 2 02:41:32 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 ]
On 10/1/05, Travis Oliphant <oliphant at ee.byu.edu> wrote:
The new ndarray object of scipy core (successor to Numeric Python) is a C extension type that has a getitem defined in both the asmapping and the assequence structure. The assequence mapping is just so PySequenceGetItem will work correctly. As exposed to Python the ndarray object has a .getitem wrapper method. Why does this wrapper call the sequence getitem instead of the mapping getitem method? Is there anyway to get at a mapping-style getitem method from Python?
Hmm... I'm sure the answer is in typeobject.c, but that is one of the more obfuscated parts of Python's guts. I wrote it four years ago and since then I've apparently lost enough brain cells (or migrated them from language implementation to to language design service :) that I don't understand it inside out any more like I did while I was in the midst of it.
However, I wonder if the logic isn't such that if you define both sq_item and mp_subscript, getitem calls sq_item; I wonder if by removing sq_item it might call mp_subscript? Worth a try, anyway.
-- --Guido van Rossum (home page: http://www.python.org/~guido/)
- 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 ]