[Python-Dev] I think my set module is ready for prime time; comments?

Tim Peters tim.one@home.com
Wed, 24 Jan 2001 04:24:26 -0500

[Greg Ewing]
> This could be incorporated into PyDict. Instead of storing keys and
> values in the same array, keep them in separate arrays and only
> allocate the values array the first time someone stores a value other
> than 1.

> Not a bad idea!

In theory, but if Vladimir were here he'd bust a gut over the possibly bad
cache effects on "real dicts" (by keeping everything together, simply
accessing the cached hash code brings both the key and value pointers into
L1 cache too).  We would need to quantify the effect of breaking that

> (But shouldn't the default value be something else,
> like none?)

Bleech.  I hate the idiom of using a false value to mean "present".

    d = {}
    for x in seq:
        d[x] = 1

runs faster too (None needs a LOAD_GLOBAL now).