When reading large file of objects, encoded with MessagePack it is important to know object offset. If you use f.tell() it returns read buffer offset, not actual object offset. It would be great to have some thing like this: ``` python unpacker = msgpack.Unpacker(stream) for obj in unpacker: offset = unpacker.tell() ``` Or even this: ``` python unpacker = msgpack.Unpacker(stream, tell=True) for offset, obj in unpacker: # ... ```
Activity
jnothman commentedon Oct 15, 2013
This sort of low-level file tracking can be achieved through the
write_bytesarg toUnpacker.unpack,Unpacker.skip, etc. For example:(Yes, it will be slower than if
tellwere natively supported.)sirex commentedon Oct 16, 2013
@jnothman thanks, some how I missed this write_bytes parameter, and it solves my issue.
Now, as a workaround I packb obj and count bytes in it, to get offset, but using write_bytes is much more efficient. Thank again.