[Python-Dev] inheriting basic types more efficiently

Josiah Carlson jcarlson at uci.edu
Thu Apr 27 08:20:13 CEST 2006


Dennis Heuer <dh at triple-media.com> wrote:
> 
> OK, let's get back to the bitarray type. To first be clear about the
> *type* of bitarray: The type I talk about is really a *bit*-array and
> not a *bytewise*-array, as most developers seem to think of it. The
> array doesn't provide the boolean manipulation of single bytes in the
> array, it provides the manipulation of single bits or slices of bits in
> a bit sequence of unlimited length. Think of it like of a data sequence
> for a touring mashine (just bits).

Rather than trying to force bitarrays into longs (which will actually
tend to be much slower than necessary), you could use actual arrays
(using 8, 16, or 32 bit integers), and just mask the final few bits as
necessary.  See this post:
    http://lists.copyleft.no/pipermail/pyrex/2005-October/001502.html
for a sample implementation in Python.

 - Josiah



More information about the Python-Dev mailing list