On 10/1/05, Travis Oliphant <[EMAIL PROTECTED]> 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 as_mapping and > the as_sequence structure. > > The as_sequence mapping is just so PySequence_GetItem 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/) _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com