diff options
author | Raymond Hettinger <python@rcn.com> | 2004-03-18 02:41:19 (GMT) |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2004-03-18 02:41:19 (GMT) |
commit | 019a148c7221efa8292dad547170282799b23e13 (patch) | |
tree | c9941c3334dbe02e304a65b53c77e1b2fac70746 /Objects/dictnotes.txt | |
parent | 65d63424b4b1d705830f582f2a43634377f59433 (diff) | |
download | cpython-019a148c7221efa8292dad547170282799b23e13.zip cpython-019a148c7221efa8292dad547170282799b23e13.tar.gz cpython-019a148c7221efa8292dad547170282799b23e13.tar.bz2 |
Optimize dictionary iterators.
* Split into three separate types that share everything except the
code for iternext. Saves run time decision making and allows
each iternext function to be specialized.
* Inlined PyDict_Next(). In addition to saving a function call, this
allows a redundant test to be eliminated and further specialization
of the code for the unique needs of each iterator type.
* Created a reusable result tuple for iteritems(). Saves the malloc
time for tuples when the previous result was not kept by client code
(this is the typical use case for iteritems). If the client code
does keep the reference, then a new tuple is created.
Results in a 20% to 30% speedup depending on the size and sparsity
of the dictionary.
Diffstat (limited to 'Objects/dictnotes.txt')
0 files changed, 0 insertions, 0 deletions