(-1)**1000
Tim Chase
python.list at tim.thechases.com
Wed Oct 22 06:43:02 EDT 2014
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
More information about the Python-list
mailing list