1
- ===========================
2
- MessagePack Python Binding
3
- ===========================
1
+ =======================
2
+ MessagePack for Python
3
+ =======================
4
4
5
5
:author: INADA Naoki
6
6
:version: 0.3.0
@@ -9,30 +9,53 @@ MessagePack Python Binding
9
9
.. image :: https://secure.travis-ci.org/msgpack/msgpack-python.png
10
10
:target: https://travis-ci.org/#!/msgpack/msgpack-python
11
11
12
- WHAT IT IS
13
- ----------
12
+ What's this
13
+ ------------
14
14
15
15
`MessagePack <http://msgpack.org/ >`_ is a fast, compact binary serialization format, suitable for
16
16
similar data to JSON. This package provides CPython bindings for reading and
17
17
writing MessagePack data.
18
18
19
- NOTE for msgpack 0.2.x users
19
+ Install
20
+ ---------
21
+ You can use ``pip `` or ``easy_install `` to install msgpack::
22
+
23
+ $ easy_install msgpack-python
24
+ or
25
+ $ pip install msgpack-python
26
+
27
+ PyPy
28
+ ^^^^^
29
+
30
+ msgpack-python provides pure python implementation.
31
+ PyPy can use this.
32
+
33
+ Windows
34
+ ^^^^^^^
35
+
36
+ When you can't use binary distribution, you need to install Visual Studio
37
+ or Windows SDK on Windows. (NOTE: Visual C++ Express 2010 doesn't support
38
+ amd64. Windows SDK is recommanded way to build amd64 msgpack without any fee.)
39
+
40
+ Without extension, using pure python implementation on CPython runs slowly.
41
+
42
+ Note for msgpack 0.2.x users
20
43
----------------------------
21
44
22
45
The msgpack 0.3 have some incompatible changes.
23
46
24
- The default value of ``use_list `` keyword argument is ``True `` from 0.3.x.
47
+ The default value of ``use_list `` keyword argument is ``True `` from 0.3.
25
48
You should pass the argument explicitly for backward compatibility.
26
49
27
50
`Unpacker.unpack() ` and some unpack methods now raises `OutOfData `
28
51
instead of `StopIteration `.
29
52
`StopIteration ` is used for iterator protocol only.
30
53
31
54
32
- HOW TO USE
55
+ How to use
33
56
-----------
34
57
35
- one -shot pack & unpack
58
+ One -shot pack & unpack
36
59
^^^^^^^^^^^^^^^^^^^^^^
37
60
38
61
Use ``packb `` for packing and ``unpackb `` for unpacking.
@@ -60,7 +83,7 @@ You should always pass the ``use_list`` keyword argument. See performance issues
60
83
Read the docstring for other options.
61
84
62
85
63
- streaming unpacking
86
+ Streaming unpacking
64
87
^^^^^^^^^^^^^^^^^^^
65
88
66
89
``Unpacker `` is a "streaming unpacker". It unpacks multiple objects from one
@@ -82,7 +105,7 @@ stream (or from bytes provided through its ``feed`` method).
82
105
print unpacked
83
106
84
107
85
- packing /unpacking of custom data type
108
+ Packing /unpacking of custom data type
86
109
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
87
110
88
111
It is also possible to pack/unpack custom data types. Here is an example for
@@ -118,7 +141,7 @@ It is also possible to pack/unpack custom data types. Here is an example for
118
141
key-value pairs.
119
142
120
143
121
- advanced unpacking control
144
+ Advanced unpacking control
122
145
^^^^^^^^^^^^^^^^^^^^^^^^^^
123
146
124
147
As an alternative to iteration, ``Unpacker `` objects provide ``unpack ``,
@@ -150,27 +173,8 @@ callback function:
150
173
unpacker.skip(bytestream.write)
151
174
worker.send(bytestream.getvalue())
152
175
153
- INSTALL
154
- ---------
155
- You can use ``pip `` or ``easy_install `` to install msgpack::
156
-
157
- $ easy_install msgpack-python
158
- or
159
- $ pip install msgpack-python
160
-
161
-
162
- Windows
163
- ^^^^^^^
164
- msgpack provides some binary distribution for Windows.
165
- You can install msgpack without compiler with them.
166
-
167
- When you can't use binary distribution, you need to install Visual Studio
168
- or Windows SDK on Windows. (NOTE: Visual C++ Express 2010 doesn't support
169
- amd64. Windows SDK is recommanded way to build amd64 msgpack without any fee.)
170
-
171
-
172
- PERFORMANCE NOTE
173
- -----------------
176
+ Note about performance
177
+ ------------------------
174
178
175
179
GC
176
180
^^
@@ -179,8 +183,8 @@ CPython's GC starts when growing allocated object.
179
183
This means unpacking may cause useless GC.
180
184
You can use ``gc.disable() `` when unpacking large message.
181
185
182
- use_list
183
- ^^^^^^^^^
186
+ ` use_list ` option
187
+ ^^^^^^^^^^^^^^^^^^
184
188
List is the default sequence type of Python.
185
189
But tuple is lighter than list.
186
190
You can use ``use_list=False `` while unpacking when performance is important.
@@ -190,13 +194,12 @@ Python's dict can't use list as key and MessagePack allows array for key of mapp
190
194
Another way to unpacking such object is using ``object_pairs_hook ``.
191
195
192
196
193
- TEST
197
+ Test
194
198
----
195
199
MessagePack uses `pytest ` for testing.
196
200
Run test with following command:
197
201
198
202
$ py.test
199
203
200
-
201
204
..
202
205
vim: filetype=rst
0 commit comments