summaryrefslogtreecommitdiffstats
path: root/Modules/cmathmodule.c
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2004-03-18 02:41:19 (GMT)
committerRaymond Hettinger <python@rcn.com>2004-03-18 02:41:19 (GMT)
commit019a148c7221efa8292dad547170282799b23e13 (patch)
treec9941c3334dbe02e304a65b53c77e1b2fac70746 /Modules/cmathmodule.c
parent65d63424b4b1d705830f582f2a43634377f59433 (diff)
downloadcpython-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 'Modules/cmathmodule.c')
0 files changed, 0 insertions, 0 deletions