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

BartC bc at freeuk.com
Mon Mar 7 21:02:59 EST 2016


On 08/03/2016 01:40, Chris Angelico wrote:
> On Tue, Mar 8, 2016 at 12:33 PM, BartC <bc at freeuk.com> wrote:

>> Let me ask you a follow-on question first: how slow does a new Python
>> version have to be before even you would take notice?
>>
>> Compared with 2.7, 3.4 above is spending nearly an extra ten seconds doing
>> .... what? I can't understand why someone just wouldn't care.
>
> Performance matters, when you actually have something useful to
> measure. Startup performance matters enormously if interpreter startup
> is what you're doing a lot of (for example, the "feel" of Mercurial
> depends heavily on Python startup performance). It matters not a whit
> if your process keeps running for a long time, and handles many
> requests (for example, a web server).
>
> You need to be VERY clear about exactly what you're measuring. Are you
> using the 'timeit' module to measure execution of one line of code?
> Are you putting your code into a file and running that with
> /usr/bin/time? Are you putting the code into Idle and running it in a
> loop with 'exec' and using time.time() around the outside? Your
> numbers do not concern me *because they mean nothing*.

So they're just random numbers?

I write interpreters. If I suddenly saw a 115% increase in runtime from 
one version to another, /even on a trivial 2-line loop/ (or even on 
/any/ program doing the same task), then I'd want to know why! Because 
experience tells me that something is wrong.

Of course I don't know here what they've been doing to Python. Maybe 
they know exactly why it's slower. But then they should explain why it 
is, otherwise it could be a bug. Maybe someone left a debug flag turned 
on or something. Or there's some other technical reason, but it would be 
nice to know what it is.

-- 
Bartc



More information about the Python-list mailing list