8000 Update README. · zhurs/msgpack-python@cb78959 · GitHub
[go: up one dir, main page]

Skip to content

Commit cb78959

Browse files
committed
Update README.
1 parent 84dc99c commit cb78959

File tree

1 file changed

+35
-3
lines changed

1 file changed

+35
-3
lines changed

README.rst

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ MessagePack for Python
33
=======================
44

55
:author: INADA Naoki
6-
:version: 0.3.0
7-
:date: 2012-12-07
6+
:version: 0.4.0
7+
:date: 2013-10-21
88

99
.. image:: https://secure.travis-ci.org/msgpack/msgpack-python.png
1010
:target: https://travis-ci.org/#!/msgpack/msgpack-python
@@ -39,8 +39,40 @@ amd64. Windows SDK is recommanded way to build amd64 msgpack without any fee.)
3939

4040
Without extension, using pure python implementation on CPython runs slowly.
4141

42+
Notes
43+
-----
44+
45+
Note for msgpack 2.0 support
46+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
47+
48+
msgpack 2.0 adds two types: *bin* and *ext*.
49+
50+
*raw* was bytes or string type like Python 2's ``str``.
51+
To distinguish string and bytes, msgpack 2.0 adds *bin*.
52+
It is non-string binary like Python 3's ``bytes``.
53+
54+
To use *bin* type for packing ``bytes``, pass ``use_bin_type=True`` to
55+
packer argument.
56+
57+
>>> import msgpack
58+
>>> packed = msgpack.packb([b'spam', u'egg'], use_bin_type=True)
59+
>>> msgpack.unpackb(packed, encoding='utf-8')
60+
['spam', u'egg']
61+
62+
You shoud use it carefully. When you use ``use_bin_type=True``, packed
63+
binary can be unpacked by unpackers supporting msgpack-2.0.
64+
65+
To use *ext* type, pass ``msgpack.ExtType`` object to packer.
66+
67+
>>> import msgpack
68+
>>> packed = msgpack.packb(msgpack.ExtType(42, b'xyzzy'))
69+
>>> msgpack.unpackb(packed)
70+
ExtType(code=42, data='xyzzy')
71+
72+
You can use it with ``default`` and ``ext_hook``. See below.
73+
4274
Note for msgpack 0.2.x users
43-
----------------------------
75+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
4476

4577
The msgpack 0.3 have some incompatible changes.
4678

0 commit comments

Comments
 (0)
0