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

Ben Finney ben+python at benfinney.id.au
Wed Mar 9 21:29:54 EST 2016


BartC <bc at freeuk.com> writes:

> But, someone had to write that Image.PNG.encode() function at some
> time. What language did they use? If it wasn't Python, then why not?

Because some operations actually need to be very fast, even at the
expense of difficult-to-maintain code in a difficult-to-use language.

> Why is it OK to let some poor sod slave away in C++ or whatever (a
> ghastly language), while others then reap the benefits writing in an
> easy 'soft' language?

Because that's the whole point of writing a small re-usable library and
maintaining it: countless gobs of badly-written imitations thereby never
need to be written.

> I've been interested for a while in broadening the scope of scripting
> languages so that less work has to be done in 'hard' ones.

Yes, that's pretty much the answer to the question you asked above.

> But the attitude in this group has been very different; Python /is/
> slow, but so what? Just a general shrug.

I'm sorry you drew that inference. Comprehensive answers – not a
“general shrug” – have in fact been given to you.

The answer boils down to the fact that there are trade-offs to be made.
One that is easy to express is that Python trades preserving valuable
programmer time, at the expense of some non-critical operations being
slightly slower.

And no, of course it's not “Python is slow”. Such a broad statement is
erxactly what gets mocking scorn in response: you need to be *much* more
specific about what is slow, under what conditions. Python is plenty
fast enough at most of the things it is used for.

> So long as /someone else/ uses the hard language to created the needed
> libraries, the speed of pure Python is irrelevant. New version of
> Python is now half the speed? Another shrug!

Citation needed. I don't know of any released version of Python that was
ever “twice as slow” – no qualifiers – than the previous release.

Make such sweeping, hand-waving statements that are trivially
demonstrated false, and yes your statements will be dismissed. With
sneers by some, and with a shrug by most.

-- 
 \       “It's easy to play any musical instrument: all you have to do |
  `\       is touch the right key at the right time and the instrument |
_o__)                        will play itself.” —Johann Sebastian Bach |
Ben Finney




More information about the Python-list mailing list