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

BartC bc at freeuk.com
Tue Mar 8 20:28:12 EST 2016


On 09/03/2016 00:04, Steven D'Aprano wrote:
> On Wed, 9 Mar 2016 12:49 am, BartC wrote:
>
>>> 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!
>
>
> Possibly a really amateurish, lazy job, but still done.
>
> So now when you can't process a file, you silently exit, giving no
> indication that there was a problem or what the problem was. You suppress
> the helpful traceback, making sure that it is as difficult as possible for
> the user to diagnose the problem. You even exit with an exit code of 0
> ("success") in order to confuse any scripts they use. Brilliant! I love
> helpful tools like that!
>
> How many years did you say you have been programming?

You forget to mention that the name of the input file is hard-coded, 
making it awkward to use from a script.

That might give you a clue that it's not a serious, polished utility.

It's just a test, primarily as something useful for PyPy to get its 
teeth into, but it's also the first time I'd ported a sizeable program 
into Python.

(Which wasn't as painful as I'd expected. However the next project I 
have in mind is 20K lines rather than 0.7K. For that I'm looking at some 
mechanical translation I think. And probably some library to wrap around 
Python's i/o.)

-- 
Bartc



More information about the Python-list mailing list