STINNER Victor added the comment: bench_long.py: micro-benchmark for x+y. I confirm a slow down with 21955.patch. IMO you should at least inline PyLong_AsLong() which can be simplified if the number has 0 or 1 digit. Here is my patch "inline.patch" which is 21955.patch with PyLong_AsLong() inlined.
Benchmark result (patch=21955.patch, inline=inline.patch): Common platform: Platform: Linux-3.14.8-200.fc20.x86_64-x86_64-with-fedora-20-Heisenbug CPU model: Intel(R) Core(TM) i7-2600 CPU @ 3.40GHz Bits: int=32, long=64, long long=64, size_t=64, void*=64 CFLAGS: -Wno-unused-result -Werror=declaration-after-statement -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes Timer info: namespace(adjustable=False, implementation='clock_gettime(CLOCK_MONOTONIC)', monotonic=True, resolution=1e-09) Python unicode implementation: PEP 393 Timer: time.perf_counter Platform of campaign orig: Date: 2014-07-16 10:04:27 Python version: 3.5.0a0 (default:08b3ee523577, Jul 16 2014, 10:04:23) [GCC 4.8.2 20131212 (Red Hat 4.8.2-7)] SCM: hg revision=08b3ee523577 tag=tip branch=default date="2014-07-15 13:23 +0300" Timer precision: 40 ns Platform of campaign patch: Timer precision: 40 ns Date: 2014-07-16 10:04:01 Python version: 3.5.0a0 (default:08b3ee523577+, Jul 16 2014, 10:02:12) [GCC 4.8.2 20131212 (Red Hat 4.8.2-7)] SCM: hg revision=08b3ee523577+ tag=tip branch=default date="2014-07-15 13:23 +0300" Platform of campaign inline: Timer precision: 31 ns Date: 2014-07-16 10:11:21 Python version: 3.5.0a0 (default:08b3ee523577+, Jul 16 2014, 10:10:48) [GCC 4.8.2 20131212 (Red Hat 4.8.2-7)] SCM: hg revision=08b3ee523577+ tag=tip branch=default date="2014-07-15 13:23 +0300" --------------------+-------------+---------------+--------------- Tests | orig | patch | inline --------------------+-------------+---------------+--------------- 1+2 | 23 ns (*) | 24 ns | 21 ns (-12%) "1+2" ran 100 times | 1.61 us (*) | 1.74 us (+7%) | 1.39 us (-14%) --------------------+-------------+---------------+--------------- Total | 1.64 us (*) | 1.76 us (+7%) | 1.41 us (-14%) --------------------+-------------+---------------+--------------- (I removed my message because I posted the wrong benchmark output, inline column was missing.) ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue21955> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com