Followup of discussion in 04289cc
Python 2 bytearray mutations
== run_benchmark_process_xor.py
max = 2147483543
34.8218421936
0.414654970169
Python 3 bytearray mutations
== run_benchmark_process_xor.py
max = 2147483543
33.529802142000335
0.39478560099996685
Python 3 iterating bytes
== run_benchmark_process_xor.py
max = 2147483543
32.42236607199993
0.39769275300022855
Python 2 numpy bitwise_xor
== run_benchmark_process_xor.py
max = 2147483543
27.3349659443
0.424569129944
Python 3 numpy bitwise_xor
== run_benchmark_process_xor.py
max = 2147483543
24.56664780200026
0.4790448710000419
Conclusions:
- On real world example difference between bytearray mutations and map over bytes for Python 3 is not worth maintaining the separate code path.
- numpy's bitwise_xor gives significant performance increase, however it requires manual key wrapping as bitwise_xor expects arrays of the same size
As numpy contains C extensions and may require compilation, I suggest adding numpy as an optional dependency and falling back to native Python bytearray mutations + xor if numpy is not installed.
Followup of discussion in 04289cc
Python 2 bytearray mutations
Python 3 bytearray mutations
Python 3 iterating bytes
Python 2 numpy bitwise_xor
Python 3 numpy bitwise_xor
Conclusions:
As numpy contains C extensions and may require compilation, I suggest adding numpy as an optional dependency and falling back to native Python bytearray mutations + xor if numpy is not installed.