Python Speed Question and Opinion

Jacek Generowicz jacek.generowicz at cern.ch
Mon Jun 7 07:53:31 EDT 2004


"Maboroshi" <n/a> writes:

> Hi I am fairly new to programming but not as such that I am a total beginner
> 
> From what I understand C and C++ are faster languages than Python.

Languages cannot be fast or slow. Their implementations, however,
differ in the speed with which they execute algorithims expressed in
those languages.

It is true that, today, most C++ implementations will tend to execute
a C++ implementation of some algorithm more quickly that Python
implementations execute a Python rendition of the same algorithm.

It is true that, today, if speed of execution of the final product is
the only factor you take into account when assessing the "speed" of a
language[1], then C and C++ will appear to be "faster" than Python.

> Also from what I understand there are Interpreted and Compiled
> languages

Languages are a means of expressing information. Whether or not they
are compiled and interpreted, depends on what one choses to do with
them.

There are computer programs which interpret some computer programming
languages[2]; these are called interpreters.

There are computer programs which translate some computer programming
languages into other computer programming languages; these are called
compilers.

There are computer programs which do a mixture of interpreting and
translating; these are sometimes called partial evaluators.

If it were to mean anything to say that a given language is compiled,
then I propose that it would mean that a compiler for that language
exists. An interpreted language would therefore be one for which an
interpreter exists.

Given those working definitions of "interpreted language" and
"compiled language", your statement seems correct: there are languages
which are both interpreted and compiled[3]. An example of such a
language is Common Lisp; most implementations of Common Lisp systems
include both an interpreter and a compiler for Common Lisp.

C++ is an interpreted language: 

  http://root.cern.ch/root/Cint.html

C++ is, of course, also a compiled language:

  http://gcc.gnu.org/

so, C++ is another example of an "Interpreted and Compiled language",
lending further support to your sattement.

> Python is an Interpreted Language, am I right?

Python is most certainly a compiled language. Python source code is
first compiled into Python bytecode. Python bytecode is usually
interpreted.

You should also note, that the languages that one typically talks
about as "fast" and "compiled" languages, are compiled to an
_interpreted_ language: machine language. The interpreter which
interprets the latter is implemented in the hardware itself.

Please think about that last point, if you are ever tempted to suggest
that interpreters, or the languages that they interpret are slow.

> Or is this completely wrong?

I'll let you draw your own conclusions.


In case I made my point too subtly: 

  Try to avoid pigeonholing languages. Trying to find out how to use
  each to your best advantage, is far more productive.

  Don't put too much faith in common wisdom.

  Try not to get in the habit of throwing mere words around. 
  Understand the concepts which are represented by the words
  you use, in the context in which you use them.

  Expressing yourself precisely and accurately is important in
  computer programming, and not only in computer programming.


HTH,



[1] Thereby overlooking two factors which, in real-world programs, are
    often at least as important, and sometimes much more important:
    speed of development, and speed of maintenance.

[2] I really should be saying "... interpret programs written in some
    computer programming languages ...", but these sentences are
    convoluted enough as it is.

[3] I am deliberately interpreting the original, ambiguous, statement
    in a way in which it was not intended to be understood.



More information about the Python-list mailing list