on a very slow function

Chris Angelico rosuav at gmail.com
Sun Oct 1 20:38:13 EDT 2017


On Mon, Oct 2, 2017 at 11:34 AM, Steve D'Aprano
<steve+python at pearwood.info> wrote:
>> change it to
>>
>>       last = (last**2 + c) % N
>>       return next
>
> Better:
>
> last = (pow(last, 2, N) + (2 % N)) % N
>
> will almost certainly be faster for large values of last.

I think possibly you mean (c % N) in the middle there? Not sure but
there ought to be a reference to c somewhere.

ChrisA



More information about the Python-list mailing list