Implement BitFieldStruct feature, add test#5
Conversation
|
Hi, thanks for your PR. |
|
Hi, I also used class BFS(BitFieldStruct):
foo = Bit(1)
_ = BitPadding(6)
bar = Bit(4)
bfs = BFS()
bf = BitFields('foo:1, padding:6, bar:4')
parse_this = b'\xff\xff'
build_this = {'foo': 1, 'bar': 15}
N = 100000
def _bf():
bf.parse(parse_this)
bf.build(build_this)
def _bfs():
bfs.parse(parse_this)
bfs.build(build_this)
%timeit _bf()
# 8.26 µs ± 21.8 ns per loop (mean ± std. dev. of 7 runs, 100000 loops each)
%timeit _bfs()
# 6.59 µs ± 71.2 ns per loop (mean ± std. dev. of 7 runs, 100000 loops each) |
|
Please, use a larger input byte array. The intention is never to parse just two bytes; also std.dev. of |
|
I don't see, why the input byte array size would matter, as the |
|
This feature seem very useful, but it will be nice if the BitFieldsStruct would be able to use normal constructs. |
Implement BitField from malinoff#5 Implement Varint Add typehint Move testcases to test_structures.py
I have ...
Hi, great package!
I have created a new class for handling bitfields as structs, so that they can be specified like in c. (unlike the current BitFields class with the string based syntax)
I created a test as well for the new feature.