scott-griffiths / bitstring

A Python module to help you manage your bits
https://bitstring.readthedocs.io/en/stable/index.html
MIT License
404 stars 68 forks source link

Indexing via a list #274

Open scott-griffiths opened 1 year ago

scott-griffiths commented 1 year ago

A new feature looks to be going into bitarray, which we could either expose directly or utilise for a performance increase in some methods: https://github.com/ilanschnell/bitarray/pull/204

>>> a = BitArray('0x0000')
>>> a[[0, 2, 7]] = 1
>>> a[[0, 2, 7]]
BitArray('0b111')
>>> del a[[0, 2, 7]]

Certainly this should be used in the implementation of set. I think a[iterable] = value is equivalent to a.set(value, iterable so that's not extra functionality. But x = a[iterable] is new - does this suggest we're missing a a.get(iterable) -> BitArray for symmetry? Is del a[iterable] actually a useful thing to be able to do? Maybe.