I have a block of msgpack'd data is created as shown below:
#!/usr/bin/env python
from io import BytesIO
import msgpack
packer = msgpack.Packer()
buf = BytesIO()
buf.write(packer.pack("foo"))
buf.write(packer.pack("bar"))
buf.write(packer.pack("baz"))
Later in my app (or a different app) I need to unpack the first two elements but want access to the third element STILL packed. The only way I have found to do that so far is to repack this third element as shown below, which is rather inefficient.
buf.seek(0)
unpacker = msgpack.Unpacker(buf)
item1 = unpacker.unpack()
item2 = unpacker.unpack()
item3 = unpacker.unpack()
packed_item3 = msgpack.pack(item3)
This gets me where I want, but I would prefer to access this this last item directly so I can pass it on to where it needs to go already packed.