Performance of int/long in Python 3
rosuav at gmail.com
Tue Mar 26 15:08:17 CET 2013
On Wed, Mar 27, 2013 at 12:38 AM, Cousin Stanley
<cousinstanley at gmail.com> wrote:
> Chris Angelico wrote:
>> Interesting, so your 3.x sum() is optimizing something somewhere.
>> Strange. Are we both running the same Python ?
>> I got those from apt-get
> I also installed python here under Debian Wheezy
> via apt-get and our versions look to be the same ....
> 2.7.3 (default, Jan 2 2013, 16:53:07) [GCC 4.7.2]
> 3.2.3 (default, Feb 20 2013, 17:02:41) [GCC 4.7.2]
> CPU : Intel(R) Celeron(R) D CPU 3.33GHz
> 2.7.3 (default, Jan 2 2013, 13:56:14) [GCC 4.7.2]
> 3.2.3 (default, Feb 20 2013, 14:44:27) [GCC 4.7.2]
> CPU : ???
> Could differences in underlying CPU architecture
> lead to our differing python integer results ?
Doubtful. I have Intel(R) Core(TM) i5-2500 CPU @ 3.30GHz quad-core
with hyperthreading, but I'm only using one core for this job. I've
run the tests several times and each time, Py2 is a shade under two
seconds for inline/range_sum, and Py3 is about 2.5 seconds for each.
Just for curiosity's sake, I spun up the tests on my reiplophobic
server, still running Ubuntu Karmic. Pentium(R) Dual-Core CPU
E6500 @ 2.93GHz.
gideon at gideon:~$ python inttime.py
2.6.4 (r264:75706, Dec 7 2009, 18:45:15)
gideon at gideon:~$ python3 inttime.py
3.1.1+ (r311:74480, Nov 2 2009, 14:49:22)
Once again, Py3 is slower on small integers than Py2. So where's the
difference with your system? This is really weird! I assume you can
repeat the tests and get the same result every time?
More information about the Python-list