bugs.python.org

Created on 2002-05-26 15:25 by rhettinger, last changed 2022-04-10 16:05 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
list.diff rhettinger, 2002-05-26 15:25 Patch to add list iterator
list2.diff rhettinger, 2002-05-31 21:07 Revised patch using PyList_Check()
Messages (5)
msg40134 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2002-05-26 15:25
Filled listobject's tp_iter slot with it's own iterator.
Speeds looping 5 to 10% (YMMV).
Only half of the speed-up comes from using tp_iter.
The rest came from code tweaking:
-- eliminate the it variable
-- invert the limit test to avoid jumps
-- bypass the GET_ITEM macro to allow index++ to be
combined with the lookup.
msg40135 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2002-05-31 18:07
Logged In: YES
user_id=6380
Very close. It looks like you are using PySequence_Check()
where you should be using PyList_Check() though, since
listiter_next() really needs it to be a list! (Two place
have this mistake.)
Apart from that, it's good! (Note that the speedup
percentage is better when you use -O. :-)
msg40136 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2002-05-31 21:07
Logged In: YES
user_id=80475
Replaced both instances with PyList_Check().
No other changes.
Re-verified compile, timings, and regression tests.
Okay to commit?
msg40137 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2002-05-31 21:28
Logged In: YES
user_id=6380
Go ahead, and then close this issue!
msg40138 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2002-05-31 21:38
Logged In: YES
user_id=80475
Committed as listobject.c 2.107 and iterobject.c 1.10
Closing patch.
History
Date User Action Args
2022-04-10 16:05:21adminsetgithub: 36649
2002-05-26 15:25:24rhettingercreate

Read the original on bugs.python.org ↗