[Tutor] how to calculate program compile time?
Alan Gauld
alan.gauld at btinternet.com
Thu Dec 8 19:53:51 CET 2011
On 08/12/11 10:59, surya k wrote:
> I'm doing puzzles where we need to write code that works as fast a possible
>
> So, how can I check the compile time of my program ?...
Why would that be helpful?
The code is only compiled the first time you use it so any second run
will use the compiled code for imported modules. Put your program in a
module and then write a driver file that imports the main program...
If you want to improve performance check the timings with the Python
profiler. Tune the bits that need tuning.
If thats still not enough look at rewriting the critical parts in Cython.
Or if that fails use C. But that should be a last resort.
--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
More information about the Tutor
mailing list