mirror of
https://github.com/msgpack/msgpack-python.git
synced 2025-11-01 10:00:54 +00:00
prepare 0.2
This commit is contained in:
parent
06ed24a529
commit
288e820293
3 changed files with 70 additions and 23 deletions
|
|
@ -1,5 +1,5 @@
|
||||||
include setup.py
|
include setup.py
|
||||||
include COPYING
|
include COPYING
|
||||||
|
include README.rst
|
||||||
recursive-include msgpack *.h *.c *.pyx *.cpp
|
recursive-include msgpack *.h *.c *.pyx *.cpp
|
||||||
recursive-include test *.py
|
recursive-include test *.py
|
||||||
recursive-include test3 *.py
|
|
||||||
|
|
|
||||||
78
README.rst
78
README.rst
|
|
@ -3,33 +3,83 @@ MessagePack Python Binding
|
||||||
===========================
|
===========================
|
||||||
|
|
||||||
:author: INADA Naoki
|
:author: INADA Naoki
|
||||||
:version: 0.1.0
|
:version: 0.2.0
|
||||||
:date: 2009-07-12
|
:date: 2012-06-27
|
||||||
|
|
||||||
HOW TO USE
|
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
|
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
|
Windows
|
||||||
''''''''
|
''''''''
|
||||||
MessagePack requires gcc currently. So you need to prepare
|
msgpack provides some binary distribution for Windows.
|
||||||
MinGW GCC.
|
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
|
TEST
|
||||||
----
|
----
|
||||||
|
|
|
||||||
13
setup.py
13
setup.py
|
|
@ -1,6 +1,6 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# coding: utf-8
|
# coding: utf-8
|
||||||
version = (0, 1, 14, 'dev')
|
version = (0, 2, 0, 'dev')
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
|
@ -59,13 +59,10 @@ del sources, libraries
|
||||||
|
|
||||||
|
|
||||||
desc = 'MessagePack (de)serializer.'
|
desc = 'MessagePack (de)serializer.'
|
||||||
long_desc = """MessagePack (de)serializer for Python.
|
f = open('README.rst')
|
||||||
|
long_desc = f.read()
|
||||||
What's MessagePack? (from http://msgpack.org/)
|
f.close()
|
||||||
|
del f
|
||||||
MessagePack is a binary-based efficient data interchange format that is
|
|
||||||
focused on high performance. It is like JSON, but very fast and small.
|
|
||||||
"""
|
|
||||||
|
|
||||||
setup(name='msgpack-python',
|
setup(name='msgpack-python',
|
||||||
author='INADA Naoki',
|
author='INADA Naoki',
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue