Bitsets in Python

Jeff Epler jepler at unpythonic.net
Thu Feb 5 15:29:29 CET 2004


On Thu, Feb 05, 2004 at 05:50:57AM -0800, Matt wrote:
> I can't find anything like it in the standard library (If I've
> overlooked it, I'd be chuffed to find out I'm wrong!).

I also don't think there's anything in the standard library for it.
I vaguely recall talk that putting this in the 'array' module might be
the right thing to do:
    >>> array.array(array.BIT, '\xaa')
    array(array.BIT, [1, 0, 1, 0, 1, 0, 1, 0])

numarray also has arrays of bool, though I have to confess I'm not sure
how they're stored:
    >>> numarray.zeros((16,), numarray.Bool)
    array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], type=Bool)

Jeff




More information about the Python-list mailing list