Author serhiy.storchaka
Recipients serhiy.storchaka
Date 2015-01-21.13:50:08
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1421848208.43.0.905402107396.issue23290@psf.upfronthosting.co.za>
In-reply-to
Content
Proposed patch makes faster creating new set from other set. The benefit is only few percents when there are no hash conflicts, but can be significant if there are hash duplicates.

$ ./python -m timeit -s "s = set(range(10**4))" -- "frozenset(s)"
Unpatched: 1000 loops, best of 3: 658 usec per loop
Patched: 1000 loops, best of 3: 620 usec per loop

$ ./python -m timeit -s "s = {i+(j<<64) for i in range(10**3) for j in range(10)}" -- "frozenset(s)"
Unpatched: 100 loops, best of 3: 6.72 msec per loop
Patched: 100 loops, best of 3: 2.05 msec per loop

$ ./python -m timeit -s "s = {i+(j<<64) for i in range(10**2) for j in range(10**2)}" -- "frozenset(s)"
Unpatched: 100 loops, best of 3: 14 msec per loop
Patched: 100 loops, best of 3: 2.67 msec per loop

It should also affect set.copy and operations which makes implicit copy (most set operators). The effect should be larger for objects with slow equality operator.

set_find_free_slot() can be used to prevent a catastrophic linear pile-up in issue23259.
History
Date User Action Args
2015-01-21 13:50:08serhiy.storchakasetrecipients: + serhiy.storchaka
2015-01-21 13:50:08serhiy.storchakasetmessageid: <1421848208.43.0.905402107396.issue23290@psf.upfronthosting.co.za>
2015-01-21 13:50:08serhiy.storchakalinkissue23290 messages
2015-01-21 13:50:08serhiy.storchakacreate