It would be an understatement to say I love this language. What used
to take me all day now takes 3 hours, and I can spend the rest of the
time on my bike thinking about the problems from a high level instead
of wrestling with arcane compiler problems, etc.
Back in the day, when looking at an interpreted language (or even
compiled ones) the first thing I would ask is, "how fast is it?"
These days, with 1ghz processor machines selling for < $500, it seldom
comes up as an issue. And of course in Py''s case you can always
''extend and embed'' your core routines for fun & profit.
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?
I realize this is a more complex question than one might think. There
are various types of code constructs that might end up with different
efficiency issues. I guess what I''m asking is, in a general sense,
how fast is it now for typical code sequences, and -- importantly --
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.
Please advise.
解决方案500, it seldom
comes up as an issue. And of course in Py''s case you can always
''extend and embed'' your core routines for fun & profit.
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?
I realize this is a more complex question than one might think. There
are various types of code constructs that might end up with different
efficiency issues. I guess what I''m asking is, in a general sense,
how fast is it now for typical code sequences, and -- importantly --
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.
Please advise.
Python is fast enough for me, especially 2.3.
Profile & code slow parts as C extensions.
Include your own assembly there if so desired.
Investigate Psyco. There was one example on this
newsgroup that showed that Python+psyco actually
outperformed the same program in compiled C.
--Irmen
dan: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.)
Andrew
da***@dalkescientific.com