Changes between Version 8 and Version 9 of Ticket #13352


Ignore:
Timestamp:
08/26/13 13:23:57 (8 years ago)
Author:
dcoudert
Comment:

I have now implemented the function in C in file popcount.h with a small wrapper. The result is a bit slower than without wrapper, but still way faster than previous method.

sage: B = Bitset('00'*10000+'1')
sage: len(B)
1
sage: %timeit len(B)
1000000 loops, best of 3: 361 ns per loop
sage: B = Bitset('10'*10000)
sage: %timeit len(B)
100000 loops, best of 3: 3.03 us per loop
sage: B = Bitset('10'*1000000)
sage: len(B)
1000000
sage: %timeit len(B)
1000 loops, best of 3: 287 us per loop

I have used the _WIN32 flag, but I'm not sure it's the good one. So if one knows the best flag to use to detect when the __builtin_popcount method is not available, please let me know.

Legend:

Unmodified
Added
Removed
Modified