Is python very slow compared to C

Steven D'Aprano steve at REMOVETHIScyber.com.au
Sun Feb 12 09:13:11 EST 2006


On Sun, 12 Feb 2006 05:31:28 -0800, =?iso-8859-1?q?Luis_M._Gonz=E1lez?=
wrote:

> You are right, we all know that, but I think the person who asked this
> question doesn't want to hear a sales pitch. He asked a very specific
> question regarding execution speed.

Read his post again. He didn't ask a specific question at all, and he
certainly didn't mention execution speed. He asked a vague, meaningless
question about whether Python was "slow compared to C".

Slow to learn? No, Python is easier to learn than C.

Slow to compile? No, Python handles compiling to byte-code transparently,
you will rarely even notice it.

Slow to debug? That depends on the nature of the bug, but generally no.
It is much easier to write correct code the first time in Python than in
C, and even if the code isn't correct, Python makes it easier (and
therefore faster) to debug it.

Slow to execute? No, for many common tasks execution speed is either fast
enough regardless of the language, or it is limited by things like user
input, I/O, memory or other factors independent of the language the code
is written in.

If the task is limited by the CPU and not I/O etc., pure Python code with
no C extensions or Psycho optimizations might be slower than C code, but
that tells us virtually nothing about whether it is too slow. After all,
my car is slower than a F-11 fighter plane, but my car is plenty fast
enough for driving to the shop and back, and a car is a far more practical
solution to the task even though a F-11 would be faster.



-- 
Steven.




More information about the Python-list mailing list