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

BartC bc at freeuk.com
Tue Mar 8 08:49:04 EST 2016


On 08/03/2016 04:40, Steven D'Aprano wrote:
> On Tuesday 08 March 2016 12:41, BartC wrote:
>
>> On 08/03/2016 01:19, Steven D'Aprano wrote:
>>> On Tue, 8 Mar 2016 07:19 am, BartC wrote:
>>>
>>>> I don't have to hand a jpeg file that it can't
>>>> decode.
>>>
>>> Run this under Python 2:
>>>
>>> from random import randint
>>> blob = [randint(0, 256) for i in range(16*1024)]
>>>
>>> with open('broken.jpg', 'wb') as f:
>>>       f.write(''.join(blob))
>>>
>>> If your software can decode that, it will be a miracle.
>>>
>>
>> That's not a jpeg file.
>
> Nevertheless, in the real world, you have to deal with corrupt JPGs and
> files mislabelled as JPGs. And "crashing" doesn't count as "deal with" :-)

OK, I changed the 'raise' line to 'exit(0)'. Job done!

(I couldn't recreate the problem easily because the common failures 
didn't call abortjpeg() at all.)

It doesn't make Py3 any faster than Py2 though...

-- 
Bartc



More information about the Python-list mailing list