This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author serhiy.storchaka
Recipients pitrou, rhettinger, serhiy.storchaka
Date 2015-01-20.10:39:16
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1421750356.2.0.166287277194.issue23282@psf.upfronthosting.co.za>
In-reply-to
Content
Currently set_lookkey() first tests entry->key == NULL, then entry->hash == hash and entry->key != dummy, and only after that entry->key == key. Proposed patch optimizes the order of comparisons. entry->key == key is tested first as for dicts. And no need to test entry->key != dummy after entry->hash == hash if entry->hash of dummy key is set to -1.

Microbenchmark which demonstrates the best case (a lot of lookups of keys existing in the set).

$ ./python -m timeit -s "a = list(range(10**6)); s1 = set(a); s2 = set(a)" -- "s1 <= s2"

Unpatched: 10 loops, best of 3: 39.4 msec per loop
Patched: 10 loops, best of 3: 35.3 msec per loop
History
Date User Action Args
2015-01-20 10:39:16serhiy.storchakasetrecipients: + serhiy.storchaka, rhettinger, pitrou
2015-01-20 10:39:16serhiy.storchakasetmessageid: <1421750356.2.0.166287277194.issue23282@psf.upfronthosting.co.za>
2015-01-20 10:39:16serhiy.storchakalinkissue23282 messages
2015-01-20 10:39:16serhiy.storchakacreate