@@ -38,7 +38,7 @@ msgpack is removed, and `import msgpack` fail.
3838
3939
4040Compatibility with the old format
41- ^^^^^^^^^^^^^^^^^^^^^^---- ^^^^^^^
41+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^
4242
4343You can use ``use_bin_type=False `` option to pack ``bytes ``
4444object into raw type in the old msgpack spec, instead of bin type in new msgpack spec.
@@ -49,6 +49,32 @@ It unpacks str (raw) type in msgpack into Python bytes.
4949See note below for detail.
5050
5151
52+ Major breaking changes in msgpack 1.0
53+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
54+
55+ * Python 2
56+
57+ * The extension module does not support Python 2 anymore.
58+ The pure Python implementation (``msgpack.fallback ``) is used for Python 2.
59+
60+ * Packer
61+
62+ * ``use_bin_type=True `` by default. bytes are encoded in bin type in msgpack.
63+ **If you are still sing Python 2, you must use unicode for all string types. **
64+ You can use ``use_bin_type=False `` to encode into old msgpack format.
65+ * ``encoding `` option is removed. UTF-8 is used always.
66+
67+ * Unpacker
68+
69+ * ``raw=False `` by default. It assumes str types are valid UTF-8 string
70+ and decode them to Python str (unicode) object.
71+ * ``encdoding `` option is rmeoved. You can use ``raw=True `` to support old format.
72+ * Default value of ``max_buffer_size `` is changed from 0 to 100 MiB.
73+ * Default value of ``strict_map_key `` is changed to True to avoid hashdos.
74+ You need to pass ``strict_map_key=False `` if you have data which contain map keys
75+ which type is not bytes or str.
76+
77+
5278Install
5379-------
5480
@@ -270,27 +296,32 @@ To use the **ext** type, pass ``msgpack.ExtType`` object to packer.
270296 You can use it with ``default `` and ``ext_hook ``. See below.
271297
272298
273- Note about performance
274- ----------------------
299+ Security
300+ ^^^^^^^^
301+
302+ To unpacking data received from unreliable source, msgpack provides
303+ two security options.
304+
305+ ``max_buffer_size `` (default: 100*1024*1024) limits the internal buffer size.
306+ It is used to limit the preallocated list size too.
275307
276- GC
277- ^^
308+ ``strict_map_key `` (default: ``True ``) limits the type of map keys to bytes and str.
309+ While msgpack spec doesn't limit the types of the map keys,
310+ there is a risk of the hashdos.
311+ If you need to support other types for map keys, use ``strict_map_key=False ``.
312+
313+
314+ Performance tips
315+ ^^^^^^^^^^^^^^^^
278316
279317CPython's GC starts when growing allocated object.
280318This means unpacking may cause useless GC.
281319You can use ``gc.disable() `` when unpacking large message.
282320
283- use_list option
284- ^^^^^^^^^^^^^^^
285-
286321List is the default sequence type of Python.
287322But tuple is lighter than list.
288323You can use ``use_list=False `` while unpacking when performance is important.
289324
290- Python's dict can't use list as key and MessagePack allows array for key of mapping.
291- ``use_list=False `` allows unpacking such message.
292- Another way to unpacking such object is using ``object_pairs_hook ``.
293-
294325
295326Development
296327-----------
0 commit comments