Python speed vs csharp
gregbrunet at NOSPAMsempersoft.com
Fri Aug 1 05:25:55 CEST 2003
"Mike" <mike at nospam.com> wrote in message
news:rkdc7poiachh.1x4jtxjzaf3zo.dlg at 40tude.net...
> Bear with me: this post is moderately long, but I hope it is
> This is an error function approximation, which gets called around 1.5
> billion times during the simulation, and takes around 3500 seconds
> under an hour) to complete. While trying to speed things up, I created
> simple test case with the code above and a main function to call it 10
> million times. The code takes roughly 210 seconds to run.
> The current execution time is acceptable, but I need to increase the
> complexity of the simulation, and will need to increase the number of
> points by around 20X, to roughly 30 billion. This will increase the
> simulation time to over a day. Since the test case code was fairly
> translated it to C and ran it. The C code runs in approximately 7.5
> seconds. That's compelling, but C isn't: part of my simulation
> parser to read an input file. I put that together in a few minutes in
> Python, but there are no corresponding string or regex libraries with
> compiler, so converting my Python code would take far more time than
> save during the resulting simulations.
> Surprisingly (to me, at least), this code executed 10 million
> 8.5 seconds - only slightly slower than the compiled C code.
> My first question is, why is the Python code, at 210 seconds, so much
I'm just a little curious how test code runs 10 million cycles in 210
seconds, while production code with runs 1.5 billion cycles in 3500
seconds. That makes your production code more efficient by roughly a
factor of 10. If so, even though folks are only quoting an improvement
factor of about 3x for Pysco and 5-6x with Pyrex, that may be sufficient
enough for your needs.
More information about the Python-list