Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 258dfeb

Browse files
committed
* Note how dummy entry re-use benefits use cases with interspersed deletes
and adds. * Note that dictionary iteration is negatively impacted by additional sparseness.
1 parent f1cfb62 commit 258dfeb

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

Objects/dictnotes.txt

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ Membership Testing
4343
Similar access patterns occur with replacement dictionaries
4444
such as with the % formatting operator.
4545

46+
Dynamic Mappings
47+
Characterized by deletions interspersed with adds and replacments.
48+
Performance benefits greatly from the re-use of dummy entries.
49+
4650

4751
Data Layout (assuming a 32-bit box with 64 bytes per cache line)
4852
----------------------------------------------------------------
@@ -91,6 +95,12 @@ keys are all strings, whether reads or writes dominate, the exact
9195
hash values of the keys (some sets of values have fewer collisions than
9296
others). Any one test or benchmark is likely to prove misleading.
9397

98+
While making a dictionary more sparse reduces collisions, it impairs
99+
iteration and key listing. Those methods loop over every potential
100+
entry. Doubling the size of dictionary results in twice as many
101+
non-overlapping memory accesses for keys(), items(), values(),
102+
__iter__(), iterkeys(), iteritems(), itervalues(), and update().
103+
94104

95105
Results of Cache Locality Experiments
96106
-------------------------------------
@@ -165,7 +175,7 @@ sizes and access patterns, the user may be able to provide useful hints.
165175
1) For example, if membership testing or lookups dominate runtime and memory
166176
is not at a premium, the user may benefit from setting the maximum load
167177
ratio at 5% or 10% instead of the usual 66.7%. This will sharply
168-
curtail the number of collisions.
178+
curtail the number of collisions but will increase iteration time.
169179

170180
2) Dictionary creation time can be shortened in cases where the ultimate
171181
size of the dictionary is known in advance. The dictionary can be

0 commit comments

Comments
 (0)