(-1)**1000
Tim Chase
python.list at tim.thechases.com
Wed Oct 22 06:43:02 EDT 2014
More information about the Python-list mailing list
Wed Oct 22 06:43:02 EDT 2014
- Previous message (by thread): (-1)**1000
- Next message (by thread): (-1)**1000
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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' > 10000000 loops, best of 3: 0.124 usec per loop > $ python3 -m timeit -s 'a = 10**100' 'a & 1' > 10000000 loops, best of 3: 0.124 usec per loop > $ python3 -m timeit -s 'a = 10**1000' 'a & 1' > 10000000 loops, best of 3: 0.122 usec per loop Just for the record, this is a one-bit even/odd check (which is useful & fast in this sign-of-large-exponent case), not a parity check (which typically counts the number of "1" bits, adds the parity bit, and asserts the result is even) -tkc
- Previous message (by thread): (-1)**1000
- Next message (by thread): (-1)**1000
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list