33[ ![ Build Status] ( https://github.com/msgpack/msgpack-python/actions/workflows/wheel.yml/badge.svg )] ( https://github.com/msgpack/msgpack-python/actions/workflows/wheel.yml )
44[ ![ Documentation Status] ( https://readthedocs.org/projects/msgpack-python/badge/?version=latest )] ( https://msgpack-python.readthedocs.io/en/latest/?badge=latest )
55
6- ## What's this
6+ ## What is this?
77
88[ MessagePack] ( https://msgpack.org/ ) is an efficient binary serialization format.
99It lets you exchange data among multiple languages like JSON.
@@ -25,21 +25,21 @@ But msgpack provides a pure Python implementation (`msgpack.fallback`) for PyPy.
2525
2626### Windows
2727
28- When you can't use a binary distribution, you need to install Visual Studio
29- or Windows SDK on Windows.
30- Without extension, using pure Python implementation on CPython runs slowly.
28+ If you can't use a binary distribution, you need to install Visual Studio
29+ or the Windows SDK on Windows.
30+ Without the extension, the pure Python implementation on CPython runs slowly.
3131
3232
3333## How to use
3434
3535### One-shot pack & unpack
3636
3737Use ` packb ` for packing and ` unpackb ` for unpacking.
38- msgpack provides ` dumps ` and ` loads ` as an alias for compatibility with
38+ msgpack provides ` dumps ` and ` loads ` as aliases for compatibility with
3939` json ` and ` pickle ` .
4040
41- ` pack ` and ` dump ` packs to a file-like object.
42- ` unpack ` and ` load ` unpacks from a file-like object.
41+ ` pack ` and ` dump ` pack to a file-like object.
42+ ` unpack ` and ` load ` unpack from a file-like object.
4343
4444``` pycon
4545>>> import msgpack
@@ -73,7 +73,7 @@ for unpacked in unpacker:
7373```
7474
7575
76- ### Packing/unpacking of custom data type
76+ ### Packing/unpacking of custom data types
7777
7878It is also possible to pack/unpack custom data types. Here is an example for
7979` datetime.datetime ` .
@@ -140,16 +140,16 @@ True
140140### Advanced unpacking control
141141
142142As an alternative to iteration, ` Unpacker ` objects provide ` unpack ` ,
143- ` skip ` , ` read_array_header ` and ` read_map_header ` methods. The former two
144- read an entire message from the stream, respectively de-serialising and returning
143+ ` skip ` , ` read_array_header ` , and ` read_map_header ` methods. The former two
144+ read an entire message from the stream, respectively deserializing and returning
145145the result, or ignoring it. The latter two methods return the number of elements
146146in the upcoming container, so that each element in an array, or key-value pair
147147in a map, can be unpacked or skipped individually.
148148
149149
150150## Notes
151151
152- ### string and binary type in old msgpack spec
152+ ### String and binary types in the old MessagePack spec
153153
154154Early versions of msgpack didn't distinguish string and binary types.
155155The type for representing both string and binary types was named ** raw** .
@@ -167,7 +167,7 @@ and `raw=True` options.
167167
168168### ext type
169169
170- To use the ** ext** type, pass ` msgpack.ExtType ` object to packer.
170+ To use the ** ext** type, pass a ` msgpack.ExtType ` object to the packer.
171171
172172``` pycon
173173>>> import msgpack
@@ -181,34 +181,34 @@ You can use it with `default` and `ext_hook`. See below.
181181
182182### Security
183183
184- To unpacking data received from unreliable source, msgpack provides
184+ When unpacking data received from an unreliable source, msgpack provides
185185two security options.
186186
187187` max_buffer_size ` (default: ` 100*1024*1024 ` ) limits the internal buffer size.
188- It is used to limit the preallocated list size too .
188+ It is also used to limit preallocated list sizes .
189189
190190` strict_map_key ` (default: ` True ` ) limits the type of map keys to bytes and str.
191- While msgpack spec doesn't limit the types of the map keys ,
192- there is a risk of the hashdos .
191+ While the MessagePack spec doesn't limit map key types ,
192+ there is a risk of a hash DoS .
193193If you need to support other types for map keys, use ` strict_map_key=False ` .
194194
195195
196196### Performance tips
197197
198- CPython's GC starts when growing allocated object .
199- This means unpacking may cause useless GC.
200- You can use ` gc.disable() ` when unpacking large message.
198+ CPython's GC starts when the number of allocated objects grows .
199+ This means unpacking may trigger unnecessary GC.
200+ You can use ` gc.disable() ` when unpacking a large message.
201201
202- List is the default sequence type of Python.
203- But tuple is lighter than list.
202+ A list is the default sequence type in Python.
203+ However, a tuple is lighter than a list.
204204You can use ` use_list=False ` while unpacking when performance is important.
205205
206206
207207## Major breaking changes in the history
208208
209209### msgpack 0.5
210210
211- Package name on PyPI was changed from ` msgpack-python ` to ` msgpack ` from 0.5.
211+ The package name on PyPI was changed from ` msgpack-python ` to ` msgpack ` in 0.5.
212212
213213When upgrading from msgpack-0.4 or earlier, do ` pip uninstall msgpack-python ` before
214214` pip install -U msgpack ` .
@@ -218,25 +218,25 @@ When upgrading from msgpack-0.4 or earlier, do `pip uninstall msgpack-python` be
218218
219219* Python 2 support
220220
221- * The extension module does not support Python 2 anymore .
221+ * The extension module no longer supports Python 2.
222222 The pure Python implementation (` msgpack.fallback ` ) is used for Python 2.
223223
224224 * msgpack 1.0.6 drops official support of Python 2.7, as pip and
225- GitHub Action ( setup-python) no longer support Python 2.7.
225+ GitHub Action " setup-python" no longer supports Python 2.7.
226226
227227* Packer
228228
229229 * Packer uses ` use_bin_type=True ` by default.
230- Bytes are encoded in bin type in msgpack .
231- * The ` encoding ` option is removed. UTF-8 is used always.
230+ Bytes are encoded in the bin type in MessagePack .
231+ * The ` encoding ` option is removed. UTF-8 is always used .
232232
233233* Unpacker
234234
235- * Unpacker uses ` raw=False ` by default. It assumes str types are valid UTF-8 string
236- and decode them to Python str (unicode) object .
235+ * Unpacker uses ` raw=False ` by default. It assumes str values are valid UTF-8 strings
236+ and decodes them to Python str (Unicode) objects .
237237 * ` encoding ` option is removed. You can use ` raw=True ` to support old format (e.g. unpack into bytes, not str).
238- * Default value of ` max_buffer_size ` is changed from 0 to 100 MiB to avoid DoS attack .
238+ * The default value of ` max_buffer_size ` is changed from 0 to 100 MiB to avoid DoS attacks .
239239 You need to pass ` max_buffer_size=0 ` if you have large but safe data.
240- * Default value of ` strict_map_key ` is changed to True to avoid hashdos .
241- You need to pass ` strict_map_key=False ` if you have data which contain map keys
242- which type is not bytes or str.
240+ * The default value of ` strict_map_key ` is changed to True to avoid hash DoS .
241+ You need to pass ` strict_map_key=False ` if you have data that contain map keys
242+ whose type is neither bytes nor str.
0 commit comments