From: olipt at mayo.edu (Travis Oliphant)
Date: Tue, 20 Apr 1999 14:01:22 -0500
Subject: Bit Arrays
In-Reply-To: <7fi9i8$n2u$1@info3.fnal.gov>
References: <7fi9i8$n2u$1@info3.fnal.gov>
Message-ID: <Pine.LNX.4.04.9904201353190.12923-100000@us2.mayo.edu>
X-UID: 1428                                                  

> Hello all,
> 
> I want to write a python program that has 26 Bit Arrays that each contain
> 1113 bits. Is there a structure in python that one can use to represent a
> bit array?
> 
> Laura Paterno

This could be done in a variety of ways.  It depends on what you want to
do with the bit arrays.

Python has a bitwise OR (|), a bitwise AND (&), and a bitwise XOR (^)
operator so you could easily make a Bit Array class that does what you
need to do from either a list object, and array object, or the Numeric
extenstions (multi)array object.  

If you use the Numeric extensions I have C-methods called packbits and
unpackbits in a module called numpyio as part of the signaltools package
at http://oliphant.netpedia.net/  that take 2-D arrays of 1's and 0's and
pack them into 8-bit bytes.  This may be overkill for you, though.


Sincerely,


Travis






