@@ -38,7 +38,7 @@ msgpack is removed, and `import msgpack` fail.
38
38
39
39
40
40
Compatibility with the old format
41
- ^^^^^^^^^^^^^^^^^^^^^^---- ^^^^^^^
41
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^
42
42
43
43
You can use ``use_bin_type=False `` option to pack ``bytes ``
44
44
object 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.
49
49
See note below for detail.
50
50
51
51
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
+
52
78
Install
53
79
-------
54
80
@@ -270,27 +296,32 @@ To use the **ext** type, pass ``msgpack.ExtType`` object to packer.
270
296
You can use it with ``default `` and ``ext_hook ``. See below.
271
297
272
298
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.
275
307
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
+ ^^^^^^^^^^^^^^^^
278
316
279
317
CPython's GC starts when growing allocated object.
280
318
This means unpacking may cause useless GC.
281
319
You can use ``gc.disable() `` when unpacking large message.
282
320
283
- use_list option
284
- ^^^^^^^^^^^^^^^
285
-
286
321
List is the default sequence type of Python.
287
322
But tuple is lighter than list.
288
323
You can use ``use_list=False `` while unpacking when performance is important.
289
324
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
-
294
325
295
326
Development
296
327
-----------
0 commit comments