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 lukasz.langa
Recipients lukasz.langa, pitrou, rhettinger
Date 2015-04-29.18:36:57
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
I got a report that summing numbers is noticably slower on Python 3. This is easily reproducible:

$ time python2.7 -c "print sum(xrange(3, 10**9, 3)) + sum(xrange(5, 10**9, 5)) - sum(xrange(15, 10**9, 15))"

real    0m6.165s
user    0m6.100s
sys     0m0.032s

$ time python3.4 -c "print(sum(range(3, 10**9, 3)) + sum(range(5, 10**9, 5)) - sum(range(15, 10**9, 15)))"

real    0m16.413s
user    0m16.086s
sys     0m0.089s

I can't tell from initial poking what's the core issue here. Both examples produce equivalent bytecode, the builtin_sum() function is only noticably different in the fact that it uses PyLong_* across the board, including PyLong_AsLongAndOverlow. We'll need to profile this, which I didn't have time for yet.
Date User Action Args
2015-04-29 18:36:58lukasz.langasetrecipients: + lukasz.langa, rhettinger, pitrou
2015-04-29 18:36:58lukasz.langasetmessageid: <>
2015-04-29 18:36:58lukasz.langalinkissue24076 messages
2015-04-29 18:36:57lukasz.langacreate