[Python-Dev] Why .index() is not a method of all sequence types ?
Joost Behrends
webmaster at h-labahn.de
Thu Mar 13 01:16:12 CET 2008
Hello,
hopefully this mailing list is the right address for the following.
Since there is a huge gap in performance between tuple(cur.execute(...))
and list(cur.execute(...)) - i saw a factor in the magnitude of 50 once -
the first has always to be chosen when sufficient. Even if that difference
would be smaller - you also document the resulting sequence as read-only
in your code. I also use deque( ... some generator ... ) frequently
(And i think, that this should have more room in tutorials for
beginners - some of them have no idea, what tuples are for).
With such a tuple tp i tried 'ix = tp.index(...)' recently and was
astonished to learn, that this doesn't work. Since we have '... in tp'
for me it seems, that it should make very little difference in
the interpreter's code, if .index() would be a method of any sequence,
mutable or not. Such a small difference, that this minor change wouldn't
deserve a PEP.
Do i overlook something here ?
Kind regards, Joost Behrends
More information about the Python-Dev
mailing list