how fast is Python?
adalke at mindspring.com
Thu Aug 21 00:00:19 CEST 2003
> However, there are definitely cases where a lot of code would need to
> be optimized, and so I ask the question: How fast is Python, compared
> to say a typical optimizing C/C++ compiler?
Highly dependent on context. I use factor of 10-20 as a ballpark,
with factor of 100 for some things like low-level string processing.
Eg, I've got a pure Python regexp engine which clocks at about x80
slower than sre.
> what could be done to optimize the interpreter? Are any parts written
> in assembly? Could things like hash tables be optimized with parallel
> units such as MMX? Etc.
Spend a few tens of millions on developing just-in-time compilers
and program analysis. That worked for Java.
Nothing is written in assembly, except that C can be considered
a portable assembly language. Otherwise ports to different platforms
would be a lot more difficult.
I would hope that the C compiler could optimize the C code
sufficiently well for the hardware, rather than tweaking the
code by hand. (Though I know of at least one person who sent
in a patch to gcc to optimize poorly written in-house code.
Rather circuitous way to fix things, but it worked.)
dalke at dalkescientific.com
More information about the Python-list