Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

What's the difference between this and the msgpack-python? #4

Closed
lxyu opened this issue Nov 14, 2013 · 3 comments
Closed

What's the difference between this and the msgpack-python? #4

lxyu opened this issue Nov 14, 2013 · 3 comments

Comments

@lxyu
Copy link

lxyu commented Nov 14, 2013

Another repo here: https://github.com/msgpack/msgpack-python

While the official site recommend this u-msgpack-python, I'm a little confused.

Both implemented in pure python and both support the latest msgpack 2.0 and both support python2/3.

So what's the difference?

@vsergeev
Copy link
Owner

Hi Lx,

I released u-msgpack-python to support msgpack 2.0 back when msgpack-python only supported the old specification (see msgpack/msgpack#154). Recently, msgpack-python added support for msgpack 2.0 as well. To answer your question:

msgpack-python should be faster when used with its native library backend (it only falls back to pure Python when the library is unavailable). msgpack-python also supports a streaming unpacking mode and finer control over the unpacking process if you need them.

u-msgpack-python has the same top-level interface as msgpack-python (packb() and unpackb()), but less tuning options and modes, and u-msgpack-python is distributed as a single file to make it easy to drop into projects (e.g. embedded Linux systems, for which it is difficult to cross-compile native Python modules for). The u- prefix is meant in the "micro" connotation, as in lightweight and easy to integrate.

There may be other differences in exception handling and how Python types are mapped to and from msgpack types. In particular, u-msgpack-python is fairly strict about unicode strings and byte strings mapping between Python and msgpack. See the main README of u-msgpack-python for documentation on this.

To my best understanding, msgpack implementations are developed ad hoc. As for the website, the list is auto-generated from Github project descriptions (see https://github.com/msgpack/website). I'm not sure why msgpack-python is not listed on there -- it always used to be. I think the author took it down temporarily to implement msgpack 2.0, but I would expect it to have been back up by now.

Thanks,
~vsergeev
Ivan Sergeev

@lxyu
Copy link
Author

lxyu commented Nov 14, 2013

Thank you very much!

@stinos
Copy link

stinos commented Sep 19, 2019

Some extra information: there is a performance difference between u-msgpack-python and the pure Python implementation of msgpack-python (the one in it's fallback.py) so if you have to make a choice it might be worth checking if it matters for you.

(I didn't want to make a separate issue for this because it's not really an 'issue', I think, and this turns up in search engines so seems worth adding info here).

For the type of objects we use, something like {'a': 35, 'b': [1.0, 2.0, 3] * 20, (1): list(range(100)), 'longerKey': 'sab' * 100} msgpack-python seems to be slightly faster than u-msgpack-python when tested on Windows with CPython 3.7, and somehow twice as fast when tested with MicroPython. However with an object like list(range(1000)) the winner is u-msgpack-python on CPython (but still about twice as slow on MicroPython).

So if you need a Python implementation and know what objects you're going to use (and they work with both implementations) and performance matters then you probably want to measure first.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants