Message242238
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))"
233333333166666668
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)))"
233333333166666668
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:58 | lukasz.langa | set | recipients:
+ lukasz.langa, rhettinger, pitrou |
2015-04-29 18:36:58 | lukasz.langa | set | messageid: <1430332618.4.0.236828536627.issue24076@psf.upfronthosting.co.za> |
2015-04-29 18:36:58 | lukasz.langa | link | issue24076 messages |
2015-04-29 18:36:57 | lukasz.langa | create | |
|