STINNER Victor added the comment: I wrote a short microbenchmark allocating objects using my benchmark.py script.
It looks like the operation "(None,) * N" is slower with calloc-3.patch, but it's unclear how much times slower it is. I don't understand why only this operation has different speed. Do you have ideas for other benchmarks? Using the timeit module: $ ./python.orig -m timeit '(None,) * 10**5' 1000 loops, best of 3: 357 usec per loop $ ./python.calloc -m timeit '(None,) * 10**5' 1000 loops, best of 3: 698 usec per loop But with different parameters, the difference is lower: $ ./python.orig -m timeit -r 20 -n '1000' '(None,) * 10**5' 1000 loops, best of 20: 362 usec per loop $ ./python.calloc -m timeit -r 20 -n '1000' '(None,) * 10**5' 1000 loops, best of 20: 392 usec per loop Results of bench_alloc.py: Common platform: CFLAGS: -Wno-unused-result -Werror=declaration-after-statement -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes CPU model: Intel(R) Core(TM) i7-2600 CPU @ 3.40GHz Python unicode implementation: PEP 393 Timer info: namespace(adjustable=False, implementation='clock_gettime(CLOCK_MONOTONIC)', monotonic=True, resolution=1e-09) Timer: time.perf_counter SCM: hg revision=462470859e57+ branch=default date="2014-04-26 19:01 -0400" Platform: Linux-3.13.8-200.fc20.x86_64-x86_64-with-fedora-20-Heisenbug Bits: int=32, long=64, long long=64, size_t=64, void*=64 Platform of campaign orig: Timer precision: 42 ns Date: 2014-04-27 12:27:26 Python version: 3.5.0a0 (default:462470859e57, Apr 27 2014, 11:52:55) [GCC 4.8.2 20131212 (Red Hat 4.8.2-7)] Platform of campaign calloc: Timer precision: 45 ns Date: 2014-04-27 12:29:10 Python version: 3.5.0a0 (default:462470859e57+, Apr 27 2014, 12:04:57) [GCC 4.8.2 20131212 (Red Hat 4.8.2-7)] -----------------------------------+--------------+--------------- Tests | orig | calloc -----------------------------------+--------------+--------------- object() | 61 ns (*) | 62 ns b'A' * 10 | 55 ns (*) | 51 ns (-7%) b'A' * 10**3 | 99 ns (*) | 94 ns b'A' * 10**6 | 37.5 us (*) | 36.6 us 'A' * 10 | 62 ns (*) | 58 ns (-7%) 'A' * 10**3 | 107 ns (*) | 104 ns 'A' * 10**6 | 37 us (*) | 36.6 us 'A' * 10**8 | 16.2 ms (*) | 16.4 ms decode 10 null bytes from ASCII | 253 ns (*) | 248 ns decode 10**3 null bytes from ASCII | 359 ns (*) | 357 ns decode 10**6 null bytes from ASCII | 78.8 us (*) | 78.7 us decode 10**8 null bytes from ASCII | 26.2 ms (*) | 25.9 ms (None,) * 10**0 | 30 ns (*) | 30 ns (None,) * 10**1 | 78 ns (*) | 77 ns (None,) * 10**2 | 427 ns (*) | 460 ns (+8%) (None,) * 10**3 | 3.5 us (*) | 3.7 us (+6%) (None,) * 10**4 | 34.7 us (*) | 37.2 us (+7%) (None,) * 10**5 | 357 us (*) | 390 us (+9%) (None,) * 10**6 | 3.86 ms (*) | 4.43 ms (+15%) (None,) * 10**7 | 50.4 ms (*) | 50.3 ms (None,) * 10**8 | 505 ms (*) | 504 ms ([None] * 10)[1:-1] | 121 ns (*) | 120 ns ([None] * 10**3)[1:-1] | 3.57 us (*) | 3.57 us ([None] * 10**6)[1:-1] | 4.61 ms (*) | 4.59 ms ([None] * 10**8)[1:-1] | 585 ms (*) | 582 ms -----------------------------------+--------------+--------------- Total | 1.19 sec (*) | 1.19 sec -----------------------------------+--------------+--------------- ---------- Added file: http://bugs.python.org/file35052/bench_alloc.py _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue21233> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com