@@ -3,33 +3,83 @@ MessagePack Python Binding
33===========================
44
55:author: INADA Naoki
6- :version: 0.1 .0
7- :date: 2009-07-12
6+ :version: 0.2 .0
7+ :date: 2012-06-27
88
99HOW TO USE
1010-----------
11- You can read document in docstring after `import msgpack `
11+
12+ one-shot pack & unpack
13+ ^^^^^^^^^^^^^^^^^^^^^^
14+
15+ Use ``packb `` for packing and ``unpackb `` for unpacking.
16+ msgpack provides ``dumps `` and ``loads `` as alias for compatibility with
17+ ``json `` and ``pickle ``.
18+
19+ ``pack `` and ``dump `` packs to file-like object.
20+ ``unpack `` and ``load `` unpacks from file-like object.
21+
22+ >>> import msgpack
23+ >>> msgpack.packb([1 , 2 , 3 ])
24+ '\x93\x01\x02\x03'
25+ >>> msgpack.unpackb(_)
26+ (1, 2, 3)
27+
28+
29+ ``unpack `` unpacks msgpack's array to Python's tuple.
30+ To unpack it to list, Use ``use_list `` option.
31+
32+ >>> msgpack.unpackb(b ' \x93\x01\x02\x03 ' , use_list = True )
33+ [1, 2, 3]
34+
35+ Read docstring for other options.
36+
37+
38+ streaming unpacking
39+ ^^^^^^^^^^^^^^^^^^^
40+
41+ ``Unpacker `` is "streaming unpacker". It unpacks multiple objects from one
42+ stream.
43+
44+ ::
45+
46+ import msgpack
47+ from io import BytesIO
48+
49+ buf = BytesIO()
50+ for i in range(100):
51+ buf.write(msgpack.packb(range(i)))
52+
53+ buf.seek(0)
54+
55+ unpacker = msgpack.Unpacker()
56+ while True:
57+ data = buf.read(4)
58+ if not data:
59+ break
60+ unpacker.seed(buf.read(16))
61+ for unpacked in unpacker:
62+ print unpacked
1263
1364
1465INSTALL
1566---------
16- Cython _ is required to build msgpack.
67+ You can use `` pip `` or `` easy_install `` to install msgpack::
1768
18- .. _Cython : http://www.cython.org/
69+ $ easy_install msgpack-python
70+ or
71+ $ pip install msgpack-python
1972
20- posix
21- ''''''
22- You can install msgpack in common way.
23-
24- $ python setup.py install
2573
2674Windows
2775''''''''
28- MessagePack requires gcc currently. So you need to prepare
29- MinGW GCC.
76+ msgpack provides some binary distribution for Windows.
77+ You can install msgpack without compiler with them.
78+
79+ When you can't use binary distribution, you need to install Visual Studio
80+ or Windows SDK on Windows. (NOTE: Visual C++ Express 2010 doesn't support
81+ amd64. Windows SDK is recommanded way to build amd64 msgpack without any fee.)
3082
31- $ python setup.py build -c mingw32
32- $ python setup.py install
3383
3484TEST
3585----
0 commit comments