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

BartC bc at freeuk.com
Tue Mar 8 14:15:34 EST 2016


On 08/03/2016 16:09, Mark Lawrence wrote:
> On 08/03/2016 11:09, BartC wrote:
>> On 08/03/2016 02:45, Mark Lawrence wrote:
>>> On 08/03/2016 01:47, BartC wrote:
>>
>>>> The Python timing for that file is around 20 seconds, time enough to
>>>> read 10000 copies from the disk.
>>>>
>>>> And a C program reads /and decodes/ the same file from the same disk in
>>>> between 0.1 and 0.2 seconds.
>>>>
>>>
>>> So how much of that time is Python startup time, compared to C which is
>>> effectively zero?
>>
>> Virtually zero as well.
>
> Nonsense.
>
>>
>> That's if by start-up time you mean how long between invoking Python
>> with the name of the main module, executing all the imports and defs in
>> the main and imported modules, until it starts properly executing code.
>>
>> In the jpeg test, perhaps 50ms. And it would not depend on the size of
>> the input since the start-up routines won't know that.
>
> How did you obtain that figure?

By printing a message followed by exit(0) just before the program was 
about to start doing its thing.

Then I timed that using:

   $time python program.py

in Linux.

But this was hardly necessary as it was so obvious: it takes 150ms to 
process a 300-pixel image, 20 seconds for a 2Mpixel one, and (I have to 
switch to PyPy here as I've never had time to hang about for it) 180 
seconds for 80Mpixel file.

Surely the start-up time would be the same no matter what the input.

-- 
Bartc



More information about the Python-list mailing list