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

Skip to content

Commit eb28ef2

Browse files
committed
New collision resolution scheme: no polynomials, simpler, faster, less
code, less memory. Tests have uncovered no drawbacks. Christian and Vladimir are the other two people who have burned many brain cells on the dict code in recent years, and they like the approach too, so I'm checking it in without further ado.
1 parent 951a884 commit eb28ef2

2 files changed

Lines changed: 130 additions & 171 deletions

File tree

Misc/NEWS

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Core
1515
To enhance the usability of the .encode() method, the special
1616
casing of Unicode object return values was dropped (Unicode objects
1717
were auto-magically converted to string using the default encoding).
18-
18+
1919
Both methods will now return whatever the codec in charge of the
2020
requested encoding returns as object, e.g. Unicode codecs will
2121
return Unicode objects when decoding is requested ("���".decode("latin-1")
@@ -116,13 +116,11 @@ Core
116116
to crash if the element comparison routines for the dict keys and/or
117117
values mutated the dicts. Making the code bulletproof slowed it down.
118118

119-
- Collisions in dicts now use polynomial division instead of multiplication
120-
to generate the probe sequence, following an idea of Christian Tismer's.
121-
This allows all bits of the hash code to come into play. It should have
122-
little or no effect on speed in ordinary cases, but can help dramatically
123-
in bad cases. For example, looking up every key in a dict d with
124-
d.keys() = [i << 16 for i in range(20000)] is approximately 500x faster
125-
now.
119+
- Collisions in dicts are resolved via a new approach, which can help
120+
dramatically in bad cases. For example, looking up every key in a dict
121+
d with d.keys() = [i << 16 for i in range(20000)] is approximately 500x
122+
faster now. Thanks to Christian Tismer for pointing out the cause and
123+
the nature of an effective cure (last December! better late than never).
126124

127125
Library
128126

0 commit comments

Comments
 (0)