Skip to content

Commit 64263df

Browse files
authored
Fix terminology in comment and add more design rationale. (#3335)
* Fix terminology in comment and add more design rationale. * Fix extra space
1 parent 5503709 commit 64263df

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

Objects/setobject.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,23 @@
1212
1313
To improve cache locality, each probe inspects a series of consecutive
1414
nearby entries before moving on to probes elsewhere in memory. This leaves
15-
us with a hybrid of linear probing and open addressing. The linear probing
15+
us with a hybrid of linear probing and randomized probing. The linear probing
1616
reduces the cost of hash collisions because consecutive memory accesses
1717
tend to be much cheaper than scattered probes. After LINEAR_PROBES steps,
18-
we then use open addressing with the upper bits from the hash value. This
19-
helps break-up long chains of collisions.
18+
we then use more of the upper bits from the hash value and apply a simple
19+
linear congruential random number genearator. This helps break-up long
20+
chains of collisions.
2021
2122
All arithmetic on hash should ignore overflow.
2223
2324
Unlike the dictionary implementation, the lookkey function can return
2425
NULL if the rich comparison returns an error.
26+
27+
Use cases for sets differ considerably from dictionaries where looked-up
28+
keys are more likely to be present. In contrast, sets are primarily
29+
about membership testing where the presence of an element is not known in
30+
advance. Accordingly, the set implementation needs to optimize for both
31+
the found and not-found case.
2532
*/
2633

2734
#include "Python.h"

0 commit comments

Comments
 (0)