[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Bitstream -- Binary Data for Humans (Posting On Python-List Prohibited)

Hi Lawrence,

Le mardi 6 mars 2018 01:20:36 UTC+1, Lawrence D?Oliveiro a ?crit?:
> On Tuesday, March 6, 2018 at 8:06:00 AM UTC+13, S?bastien Boisg?rault wrote:
> > I have released bitstream, a Python library to manage binary data
> > (at the byte or bit level), hopefully without the pain that this kind
> > of thing usually entails :)
> >    byte_index = offset / 8
> This will return a float.

The implementation is in Cython, which allows to declare types. 
The variable byte_index is defined as a size_t. 
Did I miss something? Do you mean that an intermediate float 
is used in the generated C code? I guess I should check that.
I realize now that I sometimes use the code above to get the bit
and bytes index and sometimes divmod ...

> Also I notice you count bit positions from the top of each byte, rather than from the bottom. Any reason for this?

I suppose that my mental representation of the bitstream is left-to-right (think sequence of bits) with bits being "big-endian"ish in each byte, therefore new bits enter from the left with big weights. Which should translate to your description. So, no, no specific reason for this I guess. Is one of the representation better that the other (wrt performance for example)?.