Skip to content

Instantly share code, notes, and snippets.

@methane
Created March 17, 2012 15:26
Show Gist options
  • Select an option

  • Save methane/2061159 to your computer and use it in GitHub Desktop.

Select an option

Save methane/2061159 to your computer and use it in GitHub Desktop.
In [1]: import msgpack
In [2]: packed = msgpack.packb([1,2,3])
In [3]: packed
Out[3]: '\x93\x01\x02\x03'
In [4]: packed *= 3
In [5]: len(packed)
Out[5]: 12
In [6]: unpacker = msgpack.Unpacker()
In [7]: unpacker.feed(packed[:9])
In [8]: list(unpacker)
Out[8]: [(1, 2, 3), (1, 2, 3)]
In [9]: unpacker.feed(packed[9:])
In [10]: list(unpacker)
Out[10]: [(1, 2, 3)]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment