"Chris Angelico" <ros...@gmail.com> a écrit dans le message de
news:mailman.15058.1413968065.18130.python-l...@python.org...
On Wed, Oct 22, 2014 at 7:27 PM, ast <nom...@invalid.com> wrote:
If i am writing (-1)**1000 on a python program, will the
interpreter do (-1)*(-1)*...*(-1) or something clever ?
In fact i have (-1)**N with N an integer potentially big.
Exponentiation is far more efficient than the naive implementation of
iterated multiplication.
In the very particular case of (-1)**N, I belive that Python check
the odd or even parity of N and provides the result accordingly.
I tried:
(-1)**1000000000000000000000000000000000
1
(-1)**1000000000000000000000000000000001
-1
and it is instantaneous
--
https://mail.python.org/mailman/listinfo/python-list