Python is slow?
sturlamolden at yahoo.no
Tue Sep 23 20:16:54 CEST 2008
On Sep 23, 5:31 pm, bearophileH... at lycos.com wrote:
> Well written C++ code is generally faster or much faster than similar
> Python code, but programming in Python is often simpler, and it
> generally requires less time. So it may happen that to solve a problem
> a Python program that runs in 1 hour that requires 1 hour to be
> written allows you to find the solution in less time than a C++
> program that runs in 5-10 minutes that requires you 3-4 hours to be
> written :-)
I could easily sit down and wait half an hour. I could even wait a
week for the calculation to complete. But this is a program that will
be used many times, and not just by me.
> Note that C++ is just one option, but there are other languages
> around, like CLisp or D (or even a modern JavaVM), that are often an
> acceptable compromise between Python and C/C++.
Yes, if I knew Lisp, I would have used SBCL. Java I can program. But
it is a pain in the ass for any scientific programming. F# and OCaml
look promising though.
> Note that I have written a kd-tree in both Python (with Psyco
> compulsively) and D, this is the Psyco version:http://code.activestate.com/recipes/572156/
Sure I could show you the code, Python and C++, if I had a place to
post it. It looks very different form yours though.
More information about the Python-list