Why is this question so beloved? Re: Is python really slow?

George Demmy gdemmy at layton-graphics.com
Wed May 22 11:21:23 EDT 2002


Chris <chrisl_ak at hotmail.com> writes:

> I spend a fair amount of time on perl newsgroups, having the need to use 
> perl for various parts of my job. I am now learning Python. I am a bit 
> disheartened at how common it seems to code only some of a program in 
> Python and use C for other parts, and how much discussion here involves 
> using C for X and Y. I don't have time to learn another language. I don't 
> see nearly as much discussion about doing this in the Perl newgroups. 
> Should I just be learning C instead? Is this just because of the different 
> applications python is being put to use for or because Python programmers 
> are more "multi-lingual" or is Python really so slow that one needs to go 
> to C on a more regular basis?
> 
> This is NOT flamebait... it just has me concerned that by deciding on 
> Python (after becoming semi-proficient in PHP and Perl) I might be making a 
> mistake.

"Python" is *much* "faster" than "Perl", "php", or "C" at answering
this question:

What is the integer value of 2 raised to the power of 10000?

$ time python -c 'print 2**10000'

[answer snipped]

real    0m0.416s
user    0m0.410s
sys     0m0.000s

So what do you mean? Perl coders --- bring it! C coders -- bring it!

Faster here means getting the job done with the "canonical
implementation" of the language (that's why all of the languages were
quoted). Lisp hackers would snicker having endured years of this line
of badgering, no doubt, but they are off coding logistical systems for
airlines, or some such. I've read most of the responses to your
question, and for the most part the reiterate well thought out and
accurate advice give semi-weekly on this topic. Even so, why is it
that everyone loves chining in on this question?

To the specifics of your question: If you don't have time to learn
another language, then you will likely never realize any of the
benefits that Python, and learning Python, might have to offer. These
benefits are usually longer term, and if all you value is the
instantaneous, then learning something new may not be in your best
interest. Don't let the Python zealots tell you that you can't write
maintainable code in Perl, you most certainly can. However, to do so,
you require skill and discipline that require time and dedication to
cultivate. The same is true of Python. However, Python the language is
much more consistent and free of idiosyncrasies than is Perl the
language. You can be writing idiomatic Python code relatively quickly,
which means that you can leverage the experience of legions of Master
Python Hackers just by emulating them and figure out why it's a good
idea later. Please think about why this might be true.

I love learning Perl weirdness, but that for my spare time not eaten
by netnews. If I am trying to solve problems, I often "explore" the
problem interactively in Python. If it's straight forward, it's not
really a problem, it's more of a task, and you can simply apply "the
canonical pattern" to eliminate that task. As far as speed is
concerned, I find that the time consumed by design, development,
implementation, and maintenance far exceeds run time for most of the
stuff I do. I have *never* found an instance where the difference in
runtime speed between the standard Python and Perl implementations has
been a deal breaker, YMMV. 

--
George Demmy
Layton Graphics, Inc



More information about the Python-list mailing list