New submission from Raymond Hettinger: 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 ---------- assignee: rhettinger components: Interpreter Core files: no_smalltable2.diff keywords: patch messages: 233068 nosy: rhettinger priority: low severity: normal status: open title: Remove smalltable from set objects type: performance versions: Python 3.5 Added file: http://bugs.python.org/file37535/no_smalltable2.diff _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue23106> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com