diff options
-rw-r--r-- | MANIFEST.in | 2 | ||||
-rw-r--r-- | README.rst | 78 | ||||
-rw-r--r-- | setup.py | 13 |
3 files changed, 70 insertions, 23 deletions
diff --git a/MANIFEST.in b/MANIFEST.in index 4e85759..e1912ca 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,5 +1,5 @@ include setup.py include COPYING +include README.rst recursive-include msgpack *.h *.c *.pyx *.cpp recursive-include test *.py -recursive-include test3 *.py @@ -3,33 +3,83 @@ MessagePack Python Binding =========================== :author: INADA Naoki -:version: 0.1.0 -:date: 2009-07-12 +:version: 0.2.0 +:date: 2012-06-27 HOW TO USE ----------- -You can read document in docstring after `import msgpack` + +one-shot pack & unpack +^^^^^^^^^^^^^^^^^^^^^^ + +Use ``packb`` for packing and ``unpackb`` for unpacking. +msgpack provides ``dumps`` and ``loads`` as alias for compatibility with +``json`` and ``pickle``. + +``pack`` and ``dump`` packs to file-like object. +``unpack`` and ``load`` unpacks from file-like object. + + >>> import msgpack + >>> msgpack.packb([1, 2, 3]) + '\x93\x01\x02\x03' + >>> msgpack.unpackb(_) + (1, 2, 3) + + +``unpack`` unpacks msgpack's array to Python's tuple. +To unpack it to list, Use ``use_list`` option. + + >>> msgpack.unpackb(b'\x93\x01\x02\x03', use_list=True) + [1, 2, 3] + +Read docstring for other options. + + +streaming unpacking +^^^^^^^^^^^^^^^^^^^ + +``Unpacker`` is "streaming unpacker". It unpacks multiple objects from one +stream. + +:: + + import msgpack + from io import BytesIO + + buf = BytesIO() + for i in range(100): + buf.write(msgpack.packb(range(i))) + + buf.seek(0) + + unpacker = msgpack.Unpacker() + while True: + data = buf.read(4) + if not data: + break + unpacker.seed(buf.read(16)) + for unpacked in unpacker: + print unpacked INSTALL --------- -Cython_ is required to build msgpack. +You can use ``pip`` or ``easy_install`` to install msgpack:: -.. _Cython: http://www.cython.org/ + $ easy_install msgpack-python + or + $ pip install msgpack-python -posix -'''''' -You can install msgpack in common way. - - $ python setup.py install Windows '''''''' -MessagePack requires gcc currently. So you need to prepare -MinGW GCC. +msgpack provides some binary distribution for Windows. +You can install msgpack without compiler with them. + +When you can't use binary distribution, you need to install Visual Studio +or Windows SDK on Windows. (NOTE: Visual C++ Express 2010 doesn't support +amd64. Windows SDK is recommanded way to build amd64 msgpack without any fee.) - $ python setup.py build -c mingw32 - $ python setup.py install TEST ---- @@ -1,6 +1,6 @@ #!/usr/bin/env python # coding: utf-8 -version = (0, 1, 14, 'dev') +version = (0, 2, 0, 'dev') import os import sys @@ -59,13 +59,10 @@ del sources, libraries desc = 'MessagePack (de)serializer.' -long_desc = """MessagePack (de)serializer for Python. - -What's MessagePack? (from http://msgpack.org/) - - MessagePack is a binary-based efficient data interchange format that is - focused on high performance. It is like JSON, but very fast and small. -""" +f = open('README.rst') +long_desc = f.read() +f.close() +del f setup(name='msgpack-python', author='INADA Naoki', |