Python Optimization

Mark Dickinson dickinsm at gmail.com
Sun Feb 14 20:52:51 CET 2010


On Feb 14, 4:53 pm, mukesh tiwari <mukeshtiwari.ii... at 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.This
> code also seems to be more unpythonic so how to make it look like more
> pythonic . I am trying for this problem(https://www.spoj.pl/problems/
> FACT1/).
> Thank you

One other thing:  in the 'brent' function, you're setting m to
randrange(1, n).  What's the purpose of this?  It looks to me as
though m controls the number of Pollard-Rho iterations that are
clumped together at one time (before doing a gcd operation), and using
a random number for this doesn't make a lot of sense to me.

--
Mark



More information about the Python-list mailing list