Pyhon 2.x or 3.x, which is faster?

BartC bc at freeuk.com
Tue Mar 8 17:38:23 EST 2016


On 08/03/2016 20:44, Mark Lawrence wrote:
> On 08/03/2016 19:15, BartC wrote:

>> Surely the start-up time would be the same no matter what the input.
>>
>
> Unless all of the background jobs are kicking in when you're testing.  I
> assume that you do take such factors into account, by repeating your
> tests and taking an average, or perhaps even a worst case figure.

Really, that is not necessary, although I've also lost track of the 
point you're making.

Here's a new, fuller set of figures for a 24Mpixel image, with a new 
version of PyPy that I've found:

Load from disk (4MB) and decode into memory (70MB), all using the same 
algorithm and the Python code using pure Python:

PyPy 2.7.10      17.0 seconds (PyPy 4.0.1 32-bit)
PyPy 3.2.5       23.5         (PyPy 2.4.0 32-bit)
Python 2.7.11   274           (All CPython on Windows)
Python 3.1.2    280
Python 3.4.3    352

(C                1.5         gcc -O3)
(Bart's          26.5         my bytecode language)

That Python3 (3.4 version) is still insisting on being 30% slower than 
Python2! I doubt it's just doing an extra 80 seconds' worth of start-up 
code.

But looking at the bigger picture, it's also 2000% slower than PyPy, as 
well as 23000% slower than C.

 From that point of view, I can see now why some would shrug at the 
relatively minor differences between versions of CPython.

Still, if do you have to use CPython for this task (or any task with 
this scale of runtime), it means hanging about for more than an minute 
extra with Python 3.4.


-- 
Bartc



More information about the Python-list mailing list