Re: (-1)**1000

2014-11-03 Thread Albert van der Horst
In article , Ned Batchelder wrote: >On 10/22/14 5:27 AM, ast wrote: >> >> "Chris Angelico" 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 wrote: >>>> If i

Re: (-1)**1000

2014-10-29 Thread Stefan Behnel
Ned Batchelder schrieb am 26.10.2014 um 21:45: > On 10/26/14 4:07 PM, Tony the Tiger wrote: >> On Wed, 22 Oct 2014 10:27:34 +0200, ast wrote: >> >>> If i am writing (-1)**1000 on a python program, will the interpreter do >>> (-1)*(-1)*...*(-1) or something clever

Re: (-1)**1000

2014-10-26 Thread Ned Batchelder
On 10/26/14 4:07 PM, Tony the Tiger wrote: On Wed, 22 Oct 2014 10:27:34 +0200, ast wrote: If i am writing (-1)**1000 on a python program, will the interpreter do (-1)*(-1)*...*(-1) or something clever ? Even vs. odd. It ought to know. I would assume from a set of defined rules how math works

Re: (-1)**1000

2014-10-24 Thread Dave Angel
Terry Reedy Wrote in message: > On 10/22/2014 4:27 AM, ast wrote: >> Hello >> >> If i am writing (-1)**1000 on a python program, will the >> interpreter do (-1)*(-1)*...*(-1) or something clever ? > > The answer depends on the implementation. > >>

Re: (-1)**1000

2014-10-22 Thread Terry Reedy
On 10/22/2014 4:27 AM, ast wrote: Hello If i am writing (-1)**1000 on a python program, will the interpreter do (-1)*(-1)*...*(-1) or something clever ? The answer depends on the implementation. In fact i have (-1)**N with N an integer potentially big. I do some tests that suggest that

Re: (-1)**1000

2014-10-22 Thread Ned Batchelder
On 10/22/14 5:27 AM, ast wrote: "Chris Angelico" 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 wrote: If i am writing (-1)**1000 on a python program, will the interpreter do (-1)*(-1)*...*(-1) or

Re: (-1)**1000

2014-10-22 Thread Ian Kelly
On Wed, Oct 22, 2014 at 4:43 AM, Tim Chase wrote: > On 2014-10-22 12:29, Peter Otten wrote: >> That looks like log(a) while a parity check takes constant time: >> >> $ python3 -m timeit -s 'a = 10**10' 'a & 1' >> 1000 loops, best of 3: 0.124 usec per loop >> $ python3 -m timeit -s 'a = 10**100

Re: (-1)**1000

2014-10-22 Thread Ian Kelly
On Wed, Oct 22, 2014 at 5:02 AM, Peter Otten <__pete...@web.de> wrote: > Michiel Overtoom wrote: > >> >> On Oct 22, 2014, at 12:29, Peter Otten wrote: >> >>> That looks like log(a) while a parity check takes constant time: >>> $ python3 -m timeit -s 'a = 10**10' 'a & 1' >> >> >> Do you mean 'parity

Re: (-1)**1000

2014-10-22 Thread Peter Otten
Michiel Overtoom wrote: > > On Oct 22, 2014, at 12:29, Peter Otten wrote: > >> That looks like log(a) while a parity check takes constant time: >> $ python3 -m timeit -s 'a = 10**10' 'a & 1' > > > Do you mean 'parity' as in http://en.wikipedia.org/wiki/Parity_bit ? > Because a parity bit deno

Re: (-1)**1000

2014-10-22 Thread Tim Chase
On 2014-10-22 12:29, Peter Otten wrote: > That looks like log(a) while a parity check takes constant time: > > $ python3 -m timeit -s 'a = 10**10' 'a & 1' > 1000 loops, best of 3: 0.124 usec per loop > $ python3 -m timeit -s 'a = 10**100' 'a & 1' > 1000 loops, best of 3: 0.124 usec per loo

Re: (-1)**1000

2014-10-22 Thread Michiel Overtoom
On Oct 22, 2014, at 12:29, Peter Otten wrote: > That looks like log(a) while a parity check takes constant time: > $ python3 -m timeit -s 'a = 10**10' 'a & 1' Do you mean 'parity' as in http://en.wikipedia.org/wiki/Parity_bit ? Because a parity bit denotes whether the *number* of '1' bits is

Re: (-1)**1000

2014-10-22 Thread Peter Otten
ast wrote: > > "Chris Angelico" 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 wrote: >>> If i am writing (-1)**1000 on a python program, will the >>> interprete

Re: (-1)**1000

2014-10-22 Thread ast
"Chris Angelico" 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 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 (-

Re: (-1)**1000

2014-10-22 Thread Peter Otten
ast 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. > > I do some tests that suggest that Python is clever Let's see: $ python3 Pyt

Re: (-1)**1000

2014-10-22 Thread Chris Angelico
On Wed, Oct 22, 2014 at 7:27 PM, ast 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 imple

Re: (-1)**1000

2014-10-22 Thread Jean-Michel Pichavant
- Original Message - > From: "ast" > To: python-list@python.org > Sent: Wednesday, 22 October, 2014 10:27:34 AM > Subject: (-1)**1000 > > Hello > > If i am writing (-1)**1000 on a python program, will the > interpreter do (-1)*(-1)*...*(-1) or somet

(-1)**1000

2014-10-22 Thread ast
Hello 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. I do some tests that suggest that Python is clever thx -- https://mail.python.org/mailman/listinfo/python-list