[Python-Dev] extended bitwise operations (original) (raw)

Dennis Heuer dh at triple-media.com
Thu Apr 20 12:39:44 CEST 2006


I often experiment with touring machine algorithms and play around with alternative arithmetics. I'd like to do that with python but it offers only the standard bitwise operators. They're fine if one wants to do manipulations on the full integer. However, I'd like to have direct (single) bit access to be able to implement own rules, like how to deal with the carry. There is a very nice and very very small implementation of a BitArray that can do this. It is under the LGPL. However, it provides only a handful of functions. Possibly you like to implement an own version as a python module (I'd rather like to see a default syntax that can restrict the implemented bitwise operators to single bits or groups of bits.) Please have a look at bitarray.c:

http://michael.dipperstein.com/bitlibs/bitlibs.html

There are several other versions on the net. This one is more comfortable:

http://www.koders.com/c/fid7F57E63EAE4B6028AAF3DCDB6414AD240CFB6CDD.aspx

Thanks, Dennis



More information about the Python-Dev mailing list