summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorRaymond Hettinger <rhettinger@users.noreply.github.com>2017-09-05 01:54:16 (GMT)
committerGitHub <noreply@github.com>2017-09-05 01:54:16 (GMT)
commit64263dfd182da4984c51ea33ebd597369d4196f3 (patch)
treeb543c66c80fbab511ec65f8fba03f6cf11bb3878 /Objects
parent550370957cb0e40bfc497174c95fee47d01de995 (diff)
downloadcpython-64263dfd182da4984c51ea33ebd597369d4196f3.zip
cpython-64263dfd182da4984c51ea33ebd597369d4196f3.tar.gz
cpython-64263dfd182da4984c51ea33ebd597369d4196f3.tar.bz2
Fix terminology in comment and add more design rationale. (#3335)
* Fix terminology in comment and add more design rationale. * Fix extra space
Diffstat (limited to 'Objects')
-rw-r--r--Objects/setobject.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/Objects/setobject.c b/Objects/setobject.c
index 5c61bc7..219e81d 100644
--- a/Objects/setobject.c
+++ b/Objects/setobject.c
@@ -12,16 +12,23 @@
To improve cache locality, each probe inspects a series of consecutive
nearby entries before moving on to probes elsewhere in memory. This leaves
- us with a hybrid of linear probing and open addressing. The linear probing
+ us with a hybrid of linear probing and randomized probing. The linear probing
reduces the cost of hash collisions because consecutive memory accesses
tend to be much cheaper than scattered probes. After LINEAR_PROBES steps,
- we then use open addressing with the upper bits from the hash value. This
- helps break-up long chains of collisions.
+ we then use more of the upper bits from the hash value and apply a simple
+ linear congruential random number genearator. This helps break-up long
+ chains of collisions.
All arithmetic on hash should ignore overflow.
Unlike the dictionary implementation, the lookkey function can return
NULL if the rich comparison returns an error.
+
+ Use cases for sets differ considerably from dictionaries where looked-up
+ keys are more likely to be present. In contrast, sets are primarily
+ about membership testing where the presence of an element is not known in
+ advance. Accordingly, the set implementation needs to optimize for both
+ the found and not-found case.
*/
#include "Python.h"