S Groesz 741fc41f07 fix: Bits.__getitem__/__setitem__ ignore msb_last (rtl) as documented
list() always used MSB-first bit order regardless of the msb_last
constructor flag, so indexing/slicing on an instance built with
msb_last=True silently behaved identically to the default -- the
documented "swap bit order for indexing and slicing" never happened.
__setitem__ needed a matching fix: since __setvalue() always expects
a MSB-first list, a mutated LSB-first list from list() has to be
reversed back before being passed in.

Found while wiring bits.Bits into progpib's GPIB status-byte handling
(IEEE-488.2 bit numbering is LSB-first, e.g. RQS = bit 6).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-08-24 18:27:58 -05:00
2021-04-14 00:59:02 +00:00
2020-11-19 04:23:42 +00:00
2021-04-14 02:57:57 +00:00
2021-04-14 03:27:53 +00:00
2020-10-04 01:35:46 +00:00
2021-04-14 02:57:57 +00:00
2021-04-14 03:06:08 +00:00
2021-04-14 23:34:23 +00:00

Bits

Helps manage your bits!

Intended to be compatible with Python 3.6+. Written and tested against Python 3.8.5 Ubuntu 20.04.1 LTS.

If something doesn't work in Python 3.6, it's a bug. Please report any such bugs if they are encountered.

PyPI

View on PyPI at https://pypi.org/project/binary-bits/

Install from PyPI: python3 -m pip install binary-bits --upgrade

Use in your project:

import bits

my_bytes = bits.Bytes(bytes.fromhex('deadbeef'))

Similar projects

py-flags

Description
Manage the bits
Readme MIT 75 KiB
Release 1.1.0 Latest
2021-04-13 22:13:45 -05:00
Languages
Python 95.7%
Shell 3.9%
Makefile 0.4%