[Python-Dev] extended bitwise operations

Josiah Carlson jcarlson at uci.edu
Fri Apr 21 01:39:47 CEST 2006


Dennis Heuer <dh at triple-media.com> wrote:
> 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:


Bitwise access to integers has been discussed in python-dev and
python-list for quite a while, each time being refused for one reason or
another (though it has been a while since someone has brought it up here).

Since bit arrays are arguably trivial to implement in Python (I once did
it in something like 20 lines), and because there hasn't been a
significant push from the Python user community, I can't help but be -1.

 - Josiah



More information about the Python-Dev mailing list