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 rhettinger
Recipients rhettinger
Date 2014-12-23.23:40:42
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1419378045.35.0.931278321867.issue23106@psf.upfronthosting.co.za>
In-reply-to
Content
This tracker item is here to record my efforts to re-evaluate whether we were getting much if any benefit from the smalltable in set objects.

Removing the smalltable special case and instead using a memory allocation had the following effects:

* Nice simplification of the code, greatly improving the clarity of the functions for resizing, clearing, and swapping.

* Reduced the memory consumption for sets that were already using memory allocated tables (saved the memory cost of the unused smalltable).

* Nearly doubled the time to allocate and free set objects (see timings below for CLang and GCC).

As a percentage change, the time penalty seems like a killer, but then we're talking about only 1/10th of a μsec per set.



# CLANG #########

~/base_cp/python.exe -m timeit -s 'from itertools import repeat, starmap' 'list(starmap(set, repeat((), 250000)))'
10 loops, best of 3: 39.1 msec per loop
~/cpython/python.exe -m timeit -s 'from itertools import repeat, starmap' 'list(starmap(set, repeat((), 250000)))'
10 loops, best of 3: 76.7 msec per loop
~/base_cp/python.exe -m timeit -s 'from itertools import repeat, starmap' 'list(starmap(set, repeat((), 250000)))'
10 loops, best of 3: 38.8 msec per loop
~/cpython/python.exe -m timeit -s 'from itertools import repeat, starmap' 'list(starmap(set, repeat((), 250000)))'
10 loops, best of 3: 76.6 msec per loop

~/base_cp/python.exe -m timeit '{1,2,3}'
10000000 loops, best of 3: 0.0964 usec per loop
~/cpython/python.exe -m timeit '{1,2,3}'
10000000 loops, best of 3: 0.148 usec per loop
~/base_cp/python.exe -m timeit '{1,2,3}'
10000000 loops, best of 3: 0.0964 usec per loop
~/cpython/python.exe -m timeit '{1,2,3}'
10000000 loops, best of 3: 0.149 usec per loop

# GCC-4.9 ########
~/base_cp $ ~/base_cp/python.exe -m timeit '{1,2,3}'
10000000 loops, best of 3: 0.0701 usec per loop
~/base_cp $ ~/cpython/python.exe -m timeit '{1,2,3}'
10000000 loops, best of 3: 0.155 usec per loop
~/base_cp $ ~/base_cp/python.exe -m timeit '{1,2,3}'
10000000 loops, best of 3: 0.0691 usec per loop
~/base_cp $ ~/cpython/python.exe -m timeit '{1,2,3}'
10000000 loops, best of 3: 0.157 usec per loop

~/base_cp $ ~/base_cp/python.exe -m timeit -s 'from itertools import repeat, starmap' 'list(starmap(set, repeat((), 250000)))'
10 loops, best of 3: 34.6 msec per loop
~/base_cp $ ~/cpython/python.exe -m timeit -s 'from itertools import repeat, starmap' 'list(starmap(set, repeat((), 250000)))'
10 loops, best of 3: 77 msec per loop
~/base_cp $ ~/base_cp/python.exe -m timeit -s 'from itertools import repeat, starmap' 'list(starmap(set, repeat((), 250000)))'
10 loops, best of 3: 34.1 msec per loop
~/base_cp $ ~/cpython/python.exe -m timeit -s 'from itertools import repeat, starmap' 'list(starmap(set, repeat((), 250000)))'
10 loops, best of 3: 77.3 msec per loop
History
Date User Action Args
2014-12-23 23:40:46rhettingersetrecipients: + rhettinger
2014-12-23 23:40:45rhettingersetmessageid: <1419378045.35.0.931278321867.issue23106@psf.upfronthosting.co.za>
2014-12-23 23:40:45rhettingerlinkissue23106 messages
2014-12-23 23:40:44rhettingercreate