On Feb 14, 9:48 am, Mark Dickinson <dicki...@gmail.com> wrote: > On Feb 14, 4:53 pm, mukesh tiwari <mukeshtiwari.ii...@gmail.com> > wrote: > > > Hello everyone. I am new to python and previously i did programming in > > c/c++.Could some one please help me to improve the run time for this > > python program as i don't have idea how to optimized this code. > > [...] > > How much of a speedup do you need? Are we talking about orders of > magnitude (in which case you might want to consider using something > like the Multiple Polynomial Quadratic Sieve method instead, or as > well), or just a few percent? > > (1) Have you profiled the code to see where it's spending most of its > time? This is an essential first step. >
I ditto the profiling recommendation. http://docs.python.org/library/profile.html It might also be useful to time your algorithm for n=10, 100, 1000, 10000, etc., to get a better sense of how the overall algorithm behaves. -- http://mail.python.org/mailman/listinfo/python-list