Performance of int/long in Python 3

Chris Angelico rosuav at gmail.com
Tue Mar 26 02:26:31 EDT 2013


On Tue, Mar 26, 2013 at 10:35 AM, Cousin Stanley
<cousinstanley at gmail.com> wrote:
>
> Chris Angelico wrote:
>
>> The Python 3 merge of int and long has effectively penalized
>> small-number arithmetic by removing an optimization.
>> ....
>> The cost is clear.
>> ....
>
>   The cost isn't quite as clear
>   under Debian Wheezy here ....
>
>   Stanley C. Kitching
>   Debian Wheezy
>
>   python  inline  range_sum  forloop  forloop_offset
>
>   2.7.3   3.1359  3.0725     9.0778   15.6475
>
>   3.2.3   2.8226  2.8074    13.47624  13.6430

Interesting, so your 3.x sum() is optimizing something somewhere.
Strange. Are we both running the same Python? I got those from
apt-get, aiming for consistency (rather than building a 3.3 from
source).

The cost is still visible in the for-loop versions, though, and you're
still seeing the <2^31 and >2^31 for-loops behave the same way in 3.x
but perform quite differently in 2.x. So it's looking like things are
mostly the same.

ChrisA



More information about the Python-list mailing list