# -*- coding:utf-8 -*-
import sys
import time
import time
from collections import namedtuple
t = [
("u32","n1"), #格式, 变量名称
("u6","n2"),
("u4","n3"),
( "u3","n4"),
("u3","n5"),
("u16","n6"),
("u7","n7"),
("u3","n8"),
("u6","n9"),
]
import bitarray
tmp_bytes = b"\x01\x02\x03\x04\x05\x06\x07\x08\x09\x10"
a = bitarray.bitarray(endian='little')
a.frombytes(tmp_bytes )
pos = 0
import re
num_re = re.compile("\d+")
begin = time.time()
for i in range(10000):
result = {}
for fmt, name in t:
bit_len = int( num_re.search(fmt).group() )
value = int.from_bytes( a[pos:pos+bit_len].tobytes() ,byteorder="little")
result[name] = value
pos += bit_len
last = time.time()-begin
print (last)
print (result)