ilanschnell/bitarray — pull request #20 by udoprog (2014-08-07 07:14:07+00:00)
Title: Use SIMD instructions for bitwise operations (gcc specific).

* Avoid 'case' overhead by generating BITWISE_FUNC vs. BITARRAY_FUNC.
* Change type of zero and one to (unsigned char) due to compiler complaining of
overflows on '-pedantic'. Also add 'static' to help the compiler out more.

This resulted in a ~10x speedup on large bitarrays for me using the following
test.

```python
import bitarray
import timeit

a = bitarray.bitarray(50000)
b = bitarray.bitarray(50000)

def test_and():
global a
a &= b

def test_or():
global a
a |= b

def test_xor():
global a
a ^= b

print timeit.timeit("test_and()", "from __main__ import test_and")
print timeit.timeit("test_or()", "from __main__ import test_or")
print timeit.timeit("test_xor()", "from __main__ import test_xor")
```

```
upstream master:
20.3912520409
20.6214001179
20.5252711773

with this patch:
2.11912703514
2.14890694618
2.1437420845
```

About memcpy usage in simd_v16uc_op:

I found that memcpy did the most clever thing in most cases when inspecting
compiler output.
On my system it uses movdqa to copy memory to and from xmm registers.