8000 README: `` -> ` · tsahee/msgpack-python@ff1f5f8 · GitHub
[go: up one dir, main page]

Skip to content

Commit ff1f5f8

Browse files
committed
README: ` ->
1 parent 0dad821 commit ff1f5f8

File tree

1 file changed

+37
-37
lines changed

1 file changed

+37
-37
lines changed

README.md

Lines changed: 37 additions & 37 deletions
< 628C td data-grid-cell-id="diff-b335630551682c19a781afebcf4d07bf978fb1f8ac04c6bf87428ed5106870f5-119-119-2" data-line-anchor="diff-b335630551682c19a781afebcf4d07bf978fb1f8ac04c6bf87428ed5106870f5R119" data-selected="false" role="gridcell" style="background-color:var(--bgColor-default);padding-right:24px" tabindex="-1" valign="top" class="focusable-grid-cell diff-text-cell right-side-diff-cell left-side">

Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ msgpack is removed, and `import msgpack` fail.
2828

2929
### Compatibility with the old format
3030

31-
You can use ``use_bin_type=False`` option to pack ``bytes``
31+
You can use `use_bin_type=False` option to pack `bytes`
3232
object into raw type in the old msgpack spec, instead of bin type in new msgpack spec.
3333

34-
You can unpack old msgpack format using ``raw=True`` option.
34+
You can unpack old msgpack format using `raw=True` option.
3535
It unpacks str (raw) type in msgpack into Python bytes.
3636

3737
See note below for detail.
@@ -42,23 +42,23 @@ See note below for detail.
4242
* Python 2
4343

4444
* The extension module does not support Python 2 anymore.
45-
The pure Python implementation (``msgpack.fallback``) is used for Python 2.
45+
The pure Python implementation (`msgpack.fallback`) is used for Python 2.
4646

4747
* Packer
4848

49-
* ``use_bin_type=True`` by default. bytes are encoded in bin type in msgpack.
49+
* `use_bin_type=True` by default. bytes are encoded in bin type in msgpack.
5050
**If you are still sing Python 2, you must use unicode for all string types.**
51-
You can use ``use_bin_type=False`` to encode into old msgpack format.
52-
* ``encoding`` option is removed. UTF-8 is used always.
51+
You can use `use_bin_type=False` to encode into old msgpack format.
52+
* `encoding` option is removed. UTF-8 is used always.
5353

5454
* Unpacker
5555

56-
* ``raw=False`` by default. It assumes str types are valid UTF-8 string
56+
* `raw=False` by default. It assumes str types are valid UTF-8 string
5757
and decode them to Python str (unicode) object.
58-
* ``encoding`` option is removed. You can use ``raw=True`` to support old format.
59-
* Default value of ``max_buffer_size`` is changed from 0 to 100 MiB.
60-
* Default value of ``strict_map_key`` is changed to True to avoid hashdos.
61-
You need to pass ``strict_map_key=False`` if you have data which contain map keys
58+
* `encoding` option is removed. You can use `raw=True` to support old format.
59+
* Default value of `max_buffer_size` is changed from 0 to 100 MiB.
60+
* Default value of `strict_map_key` is changed to True to avoid hashdos.
61+
You need to pass `strict_map_key=False` if you have data which contain map keys
6262
which type is not bytes or str.
6363

6464

@@ -70,10 +70,10 @@ See note below for detail.
7070

7171
### Pure Python implementation
7272

73-
The extension module in msgpack (``msgpack._cmsgpack``) does not support
73+
The extension module in msgpack (`msgpack._cmsgpack`) does not support
7474
Python 2 and PyPy.
7575

76-
But msgpack provides a pure Python implementation (``msgpack.fallback``)
76+
But msgpack provides a pure Python implementation (`msgpack.fallback`)
7777
for PyPy and Python 2.
7878

7979
Since the [pip](https://pip.pypa.io/) uses the pure Python implementation,
@@ -89,18 +89,18 @@ Without extension, using pure Python implementation on CPython runs slowly.
8989

9090
## How to use
9191

92-
NOTE: In examples below, I use ``raw=False`` and ``use_bin_type=True`` for users
92+
NOTE: In examples below, I use `raw=False` and `use_bin_type=True` for users
9393
using msgpack < 1.0. These options are default from msgpack 1.0 so you can omit them.
9494

9595

9696
### One-shot pack & unpack
9797

98-
Use ``packb`` for packing and ``unpackb`` for unpacking.
99-
msgpack provides ``dumps`` and ``loads`` as an alias for compatibility with
100-
``json`` and ``pickle``.
98+
Use `packb` for packing and `unpackb` for unpacking.
99+
msgpack provides `dumps` and `loads` as an alias for compatibility with
100+
`json` and `pickle`.
101101

102-
``pack`` and ``dump`` packs to a file-like object.
103-
``unpack`` and ``load`` unpacks from a file-like object.
102+
`pack` and `dump` packs to a file-like object.
103+
`unpack` and `load` unpacks from a file-like object.
104104

105105
```pycon
106106
>>> import msgpack
@@ -110,23 +110,23 @@ msgpack provides ``dumps`` and ``loads`` as an alias for compatibility with
110110
[1, 2, 3]
111111
```
112112

113-
``unpack`` unpacks msgpack's array to Python's list, but can also unpack to tuple:
113+
`unpack` unpacks msgpack's array to Python's list, but can also unpack to tuple:
114114

115115
```pycon
116116
>>> msgpack.unpackb(b'\x93\x01\x02\x03', use_list=False, raw=False)
117117
(1, 2, 3)
118118
```
119119
120-
You should always specify the ``use_list`` keyword argument for backward compatibility.
120+
You should always specify the `use_list` keyword argument for backward compatibility.
121121
See performance issues relating to `use_list option`_ below.
122122

123123
Read the docstring for other options.
124124

125125

126126
### Streaming unpacking
127127

128-
``Unpacker`` is a "streaming unpacker". It unpacks multiple objects from one
129-
stream (or from bytes provided through its ``feed`` method).
128+
`Unpacker` is a "streaming unpacker". It unpacks multiple objects from one
129+
stream (or from bytes provided through its `feed` method).
130130

131131
```py
132132
import msgpack
@@ -147,7 +147,7 @@ stream (or from bytes provided through its ``feed`` method).
147147
### Packing/unpacking of custom data type
148148

149149
It is also possible to pack/unpack custom data types. Here is an example for
150-
``datetime.datetime``.
150+
`datetime.datetime`.
151151

152152
```py
153153
import datetime
@@ -173,8 +173,8 @@ It is also possible to pack/unpack custom data types. Here is an example for
173173
this_dict_again = msgpack.unpackb(packed_dict, object_hook=decode_datetime, raw=False)
174174
```
175175

176-
``Unpacker``'s ``object_hook`` callback receives a dict; the
177-
``object_pairs_hook`` callback may instead be used to receive a list of
176+
`Unpacker`'s `object_hook` callback receives a dict; the
177+
`object_pairs_hook` callback may instead be used to receive a list of
178178
key-value pairs.
179179

180180

@@ -207,8 +207,8 @@ It is also possible to pack/unpack custom data types using the **ext** type.
207207

208208
### Advanced unpacking control
209209

210-
As an alternative to iteration, ``Unpacker`` objects provide ``unpack``,
211-
``skip``, ``read_array_header`` and ``read_map_header`` methods. The former two
210+
As an alternative to iteration, `Unpacker` objects provide `unpack`,
211+
`skip`, `read_array_header` and `read_map_header` methods. The former two
212212
read an entire message from the stream, respectively de-serialising and returning
213213
the result, or ignoring it. The latter two methods return the number of elements
214214
in the upcoming container, so that each element in an array, or key-value pair
@@ -222,8 +222,8 @@ in a map, can be unpacked or skipped individually.
222222
Early versions of msgpack didn't distinguish string and binary types.
223223
The type for representing both string and binary types was named **raw**.
224224

225-
You can pack into and unpack from this old spec using ``use_bin_type=False``
226-
and ``raw=True`` options.
225+
You can pack into and unpack from this old spec using `use_bin_type=False`
226+
and `raw=True` options.
227227

228228
```pycon
229229
>>> import msgpack
@@ -235,7 +235,7 @@ and ``raw=True`` options.
235235

236236
### ext type
237237

238-
To use the **ext** type, pass ``msgpack.ExtType`` object to packer.
238+
To use the **ext** type, pass `msgpack.ExtType` object to packer.
239239

240240
```pycon
241241
>>> import msgpack
@@ -244,32 +244,32 @@ To use the **ext** type, pass ``msgpack.ExtType`` object to packer.
244244
ExtType(code=42, data='xyzzy')
245245
```
246246

247-
You can use it with ``default`` and ``ext_hook``. See below.
247+
You can use it with `default` and `ext_hook`. See below.
248248

249249

250250
### Security
251251

252252
To unpacking data received from unreliable source, msgpack provides
253253
two security options.
254254

255-
``max_buffer_size`` (default: 100*1024*1024) limits the internal buffer size.
255+
`max_buffer_size` (default: `100*1024*1024`) limits the internal buffer size.
256256
It is used to limit the preallocated list size too.
257257

258-
``strict_map_key`` (default: ``True``) limits the type of map keys to bytes and str.
258+
`strict_map_key` (default: `True`) limits the type of map keys to bytes and str.
259259
While msgpack spec doesn't limit the types of the map keys,
260260
there is a risk of the hashdos.
261-
If you need to support other types for map keys, use ``strict_map_key=False``.
261+
If you need to support other types for map keys, use `strict_map_key=False`.
262262

263263

264264
### Performance tips
265265

266266
CPython's GC starts when growing allocated object.
267267
This means unpacking may cause useless GC.
268-
You can use ``gc.disable()`` when unpacking large message.
268+
You can use `gc.disable()` when unpacking large message.
269269

270270
List is the default sequence type of Python.
271271
But tuple is lighter than list.
272-
You can use ``use_list=False`` while unpacking when performance is important.
272+
You can use `use_list=False` while unpacking when performance is important.
273273

274274

275275
## Development

0 commit comments

Comments
 (0)
0