def msgpack_appendable_unpack(path):
# if not list?
# return msgpack.unpackb(f.read())
with open(path, 'rb') as f:
packer = msgpack.Packer()
unpacker = msgpack.Unpacker(f, encoding='utf-8')
length = unpacker.read_array_header()
header_lenght = len(packer.pack_array_header(length))
unpacker.read_bytes(MAX_MSGPACK_ARRAY_HEADER_LEN - header_lenght)
f.seek(MAX_MSGPACK_ARRAY_HEADER_LEN)
return [unpacker.unpack() for _ in range(length)]
评论列表
文章目录