[Python-checkins] python/dist/src/Objects dictnotes.txt,1.4,1.5
rhettinger at users.sourceforge.net
rhettinger at users.sourceforge.net
Mon Mar 15 10:52:25 EST 2004
Update of /cvsroot/python/python/dist/src/Objects
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30246
Modified Files:
dictnotes.txt
Log Message:
Fix typos and add some elaborations
Index: dictnotes.txt
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/dictnotes.txt,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** dictnotes.txt 28 May 2003 14:10:46 -0000 1.4
--- dictnotes.txt 15 Mar 2004 15:52:22 -0000 1.5
***************
*** 95,99 ****
Raising this to *4 results in half the number of resizes,
less effort to resize, better sparseness for some (but not
! all dict sizes), and potentially double memory consumption
depending on the size of the dictionary. Setting to *4
eliminates every other resize step.
--- 95,99 ----
Raising this to *4 results in half the number of resizes,
less effort to resize, better sparseness for some (but not
! all dict sizes), and potentially doubles memory consumption
depending on the size of the dictionary. Setting to *4
eliminates every other resize step.
***************
*** 113,116 ****
--- 113,118 ----
non-overlapping memory accesses for keys(), items(), values(),
__iter__(), iterkeys(), iteritems(), itervalues(), and update().
+ Also, every dictionary iterates at least twice, once for the memset()
+ when it is created and once by dealloc().
***************
*** 192,195 ****
--- 194,199 ----
ratio at 5% or 10% instead of the usual 66.7%. This will sharply
curtail the number of collisions but will increase iteration time.
+ The builtin namespace is a prime example of a dictionary that can
+ benefit from being highly sparse.
2) Dictionary creation time can be shortened in cases where the ultimate
***************
*** 200,204 ****
a more sparse environment than before. The preconditions for this
strategy arise whenever a dictionary is created from a key or item
! sequence and the number of unique keys is known.
3) If the key space is large and the access pattern is known to be random,
--- 204,208 ----
a more sparse environment than before. The preconditions for this
strategy arise whenever a dictionary is created from a key or item
! sequence and the number of *unique* keys is known.
3) If the key space is large and the access pattern is known to be random,
***************
*** 229,237 ****
jostled (to minimize collisions). The lookdict() routine can then
eliminate the test for dummy entries (saving about 1/4 of the time
! spend in the collision resolution loop).
An additional possibility is to insert links into the empty spaces
so that dictionary iteration can proceed in len(d) steps instead of
! (mp->mask + 1) steps.
--- 233,242 ----
jostled (to minimize collisions). The lookdict() routine can then
eliminate the test for dummy entries (saving about 1/4 of the time
! spent in the collision resolution loop).
An additional possibility is to insert links into the empty spaces
so that dictionary iteration can proceed in len(d) steps instead of
! (mp->mask + 1) steps. Alternatively, a separate tuple of keys can be
! kept just for iteration.
More information about the Python-checkins
mailing list