From: Benjamin Peterson Date: Fri, 1 Jan 2016 17:55:47 +0000 (-0600) Subject: merge 3.3 X-Git-Tag: v3.4.5rc1~44 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=630329e4ea03e01a830e94c06c47027e7886c6dd;p=thirdparty%2FPython%2Fcpython.git merge 3.3 --- 630329e4ea03e01a830e94c06c47027e7886c6dd diff --cc Objects/setobject.c index 304519c5d472,fc17fa560ed5..61f1d94e46be --- a/Objects/setobject.c +++ b/Objects/setobject.c @@@ -1,30 -1,7 +1,27 @@@ /* set object implementation + Written and maintained by Raymond D. Hettinger Derived from Lib/sets.py and Objects/dictobject.c. + - Copyright (c) 2003-2013 Python Software Foundation. - All rights reserved. - + The basic lookup function used by all operations. + This is based on Algorithm D from Knuth Vol. 3, Sec. 6.4. + + The initial probe index is computed as hash mod the table size. + Subsequent probe indices are computed as explained in Objects/dictobject.c. + + 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 + 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. + + All arithmetic on hash should ignore overflow. + + Unlike the dictionary implementation, the lookkey functions can return + NULL if the rich comparison returns an error. */ #include "Python.h"