ormsgpack 1.9.1__cp39-cp39-win_amd64.whl → 1.11.0__cp39-cp39-win_amd64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of ormsgpack might be problematic. Click here for more details.

ormsgpack/__init__.py CHANGED
@@ -1,6 +1,7 @@
1
1
  # SPDX-License-Identifier: (Apache-2.0 OR MIT)
2
2
 
3
3
  from .ormsgpack import (
4
+ OPT_DATETIME_AS_TIMESTAMP_EXT,
4
5
  OPT_NAIVE_UTC,
5
6
  OPT_NON_STR_KEYS,
6
7
  OPT_OMIT_MICROSECONDS,
@@ -30,6 +31,7 @@ __all__ = (
30
31
  "Ext",
31
32
  "MsgpackDecodeError",
32
33
  "MsgpackEncodeError",
34
+ "OPT_DATETIME_AS_TIMESTAMP_EXT",
33
35
  "OPT_NAIVE_UTC",
34
36
  "OPT_NON_STR_KEYS",
35
37
  "OPT_OMIT_MICROSECONDS",
ormsgpack/__init__.pyi CHANGED
@@ -4,11 +4,14 @@ __version__: str
4
4
 
5
5
  def packb(
6
6
  obj: Any,
7
+ /,
7
8
  default: Optional[Callable[[Any], Any]] = ...,
8
9
  option: Optional[int] = None,
9
10
  ) -> bytes: ...
10
11
  def unpackb(
11
12
  obj: Union[bytes, bytearray, memoryview],
13
+ /,
14
+ *,
12
15
  ext_hook: Optional[Callable[[int, bytes], Any]] = ...,
13
16
  option: Optional[int] = ...,
14
17
  ) -> Any: ...
@@ -19,6 +22,7 @@ class MsgpackEncodeError(TypeError): ...
19
22
  class Ext:
20
23
  def __init__(self, tag: int, data: bytes) -> None: ...
21
24
 
25
+ OPT_DATETIME_AS_TIMESTAMP_EXT: int
22
26
  OPT_NAIVE_UTC: int
23
27
  OPT_OMIT_MICROSECONDS: int
24
28
  OPT_PASSTHROUGH_BIG_INT: int
Binary file
@@ -0,0 +1,27 @@
1
+ Metadata-Version: 2.4
2
+ Name: ormsgpack
3
+ Version: 1.11.0
4
+ Classifier: Development Status :: 5 - Production/Stable
5
+ Classifier: Intended Audience :: Developers
6
+ Classifier: License :: OSI Approved :: Apache Software License
7
+ Classifier: License :: OSI Approved :: MIT License
8
+ Classifier: Operating System :: MacOS
9
+ Classifier: Operating System :: Microsoft :: Windows
10
+ Classifier: Operating System :: POSIX :: Linux
11
+ Classifier: Programming Language :: Python :: 3
12
+ Classifier: Programming Language :: Python :: 3.9
13
+ Classifier: Programming Language :: Python :: 3.10
14
+ Classifier: Programming Language :: Python :: 3.11
15
+ Classifier: Programming Language :: Python :: 3.12
16
+ Classifier: Programming Language :: Python :: 3.13
17
+ Classifier: Programming Language :: Python :: 3.14
18
+ Classifier: Programming Language :: Python :: Implementation :: CPython
19
+ Classifier: Programming Language :: Python :: Implementation :: PyPy
20
+ Classifier: Programming Language :: Python
21
+ Classifier: Programming Language :: Rust
22
+ Classifier: Typing :: Typed
23
+ License-File: LICENSE-APACHE
24
+ License-File: LICENSE-MIT
25
+ Home-Page: https://github.com/aviramha/ormsgpack
26
+ Author-email: Aviram Hassan <aviramyhassan@gmail.com>, Emanuele Giaquinta <emanuele.giaquinta@gmail.com>
27
+ Requires-Python: >=3.9
@@ -0,0 +1,12 @@
1
+ ormsgpack-1.11.0.dist-info/METADATA,sha256=x9CvZlb3ntSt1O4D0cPWpFUb5kbpUmTdQ2T4qWc4MjY,1244
2
+ ormsgpack-1.11.0.dist-info/WHEEL,sha256=W6WIdFr622-ULMOF24xhHMFUik89lyVEABV17NfNcas,94
3
+ ormsgpack-1.11.0.dist-info/entry_points.txt,sha256=b4bGmxqo1PPqO42Cjz2A2X4Gy4h1PCoOygCzeS-m22I,63
4
+ ormsgpack-1.11.0.dist-info/licenses/LICENSE-APACHE,sha256=fP1zjFPWHHnwfjSPYiv3cHyQhCNwVNN_vgd4inX1iBw,11048
5
+ ormsgpack-1.11.0.dist-info/licenses/LICENSE-MIT,sha256=NlFq79yExdWh50hUJZE6ItvaaesZMMXoTWrklytRlLk,1046
6
+ ormsgpack/__init__.py,sha256=A83yj4CVPWedooTwnBX0Rx2Q3SNNMinEZPS3GVWicRk,1155
7
+ ormsgpack/__init__.pyi,sha256=bxeyvolOPlRfUipaeYVCX8oZ-bX-Bu0XfQ1Dkx2CWco,965
8
+ ormsgpack/_pyinstaller/__init__.py,sha256=PiSpvMUWta2R2gVSfAut2h3Vtw9saEyF92GjC4h293E,140
9
+ ormsgpack/_pyinstaller/hook-ormsgpack.py,sha256=Bj3rdqNTDG_uR-qYnGA0GHiKshhyBrdY_xlyc0hTD_Q,118
10
+ ormsgpack/ormsgpack.cp39-win_amd64.pyd,sha256=8AlPTHpZeG4r8BEOVFZaBLSs5Qr4s4H_ky9P-UtO30U,206848
11
+ ormsgpack/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
12
+ ormsgpack-1.11.0.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: maturin (1.8.3)
2
+ Generator: maturin (1.9.6)
3
3
  Root-Is-Purelib: false
4
4
  Tag: cp39-cp39-win_amd64
@@ -1,922 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: ormsgpack
3
- Version: 1.9.1
4
- Classifier: Development Status :: 5 - Production/Stable
5
- Classifier: Intended Audience :: Developers
6
- Classifier: License :: OSI Approved :: Apache Software License
7
- Classifier: License :: OSI Approved :: MIT License
8
- Classifier: Operating System :: MacOS
9
- Classifier: Operating System :: Microsoft :: Windows
10
- Classifier: Operating System :: POSIX :: Linux
11
- Classifier: Programming Language :: Python :: 3
12
- Classifier: Programming Language :: Python :: 3.9
13
- Classifier: Programming Language :: Python :: 3.10
14
- Classifier: Programming Language :: Python :: 3.11
15
- Classifier: Programming Language :: Python :: 3.12
16
- Classifier: Programming Language :: Python :: 3.13
17
- Classifier: Programming Language :: Python :: Implementation :: CPython
18
- Classifier: Programming Language :: Python
19
- Classifier: Programming Language :: Rust
20
- Classifier: Typing :: Typed
21
- License-File: LICENSE-APACHE
22
- License-File: LICENSE-MIT
23
- Summary: Fast, correct Python msgpack library supporting dataclasses, datetimes, and numpy
24
- Keywords: fast,msgpack,dataclass,dataclasses,datetime
25
- Home-Page: https://github.com/aviramha/ormsgpack
26
- Author: Aviram Hassan <aviramyhassan@gmail.com>, Emanuele Giaquinta <emanuele.giaquinta@gmail.com>
27
- Author-email: Aviram Hassan <aviramyhassan@gmail.com>, Emanuele Giaquinta <emanuele.giaquinta@gmail.com>
28
- License: Apache-2.0 OR MIT
29
- Requires-Python: >=3.9
30
- Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
31
- Project-URL: Source Code, https://github.com/aviramha/ormsgpack
32
-
33
- # ormsgpack
34
- ![PyPI](https://img.shields.io/pypi/v/ormsgpack)
35
- ![PyPI - Downloads](https://img.shields.io/pypi/dm/ormsgpack)
36
-
37
- ormsgpack is a fast msgpack serialization library for Python derived
38
- from [orjson](https://github.com/ijl/orjson), with native support for
39
- various Python types.
40
-
41
- ormsgpack supports CPython 3.9, 3.10, 3.11, 3.12 and 3.13. Releases
42
- follow semantic versioning and serializing a new object type without
43
- an opt-in flag is considered a breaking change.
44
-
45
- ormsgpack is licensed under both the Apache 2.0 and MIT licenses. The
46
- repository and issue tracker is
47
- [github.com/aviramha/ormsgpack](https://github.com/aviramha/ormsgpack), and patches may be
48
- submitted there. There is a
49
- [CHANGELOG](https://github.com/aviramha/ormsgpack/blob/master/CHANGELOG.md)
50
- available in the repository.
51
-
52
- 1. [Usage](#usage)
53
- 1. [Install](#install)
54
- 2. [Quickstart](#quickstart)
55
- 4. [Serialize](#serialize)
56
- 1. [default](#default)
57
- 2. [option](#option)
58
- 5. [Deserialize](#deserialize)
59
- 2. [Types](#types)
60
- 1. [dataclass](#dataclass)
61
- 2. [datetime](#datetime)
62
- 3. [enum](#enum)
63
- 4. [float](#float)
64
- 5. [int](#int)
65
- 6. [numpy](#numpy)
66
- 7. [uuid](#uuid)
67
- 8. [pydantic](#pydantic)
68
- 3. [Latency](#latency)
69
- 4. [Questions](#questions)
70
- 5. [Packaging](#packaging)
71
- 6. [License](#license)
72
-
73
- ## Usage
74
-
75
- ### Install
76
-
77
- To install a wheel from PyPI:
78
-
79
- ```sh
80
- pip install --upgrade "pip>=20.3" # manylinux_x_y, universal2 wheel support
81
- pip install --upgrade ormsgpack
82
- ```
83
-
84
- To build a wheel, see [packaging](#packaging).
85
-
86
- ### Quickstart
87
-
88
- This is an example of serializing, with options specified, and deserializing:
89
-
90
- ```python
91
- >>> import ormsgpack, datetime, numpy
92
- >>> data = {
93
- ... "type": "job",
94
- ... "created_at": datetime.datetime(1970, 1, 1),
95
- ... "status": "🆗",
96
- ... "payload": numpy.array([[1, 2], [3, 4]]),
97
- ... }
98
- >>> ormsgpack.packb(data, option=ormsgpack.OPT_NAIVE_UTC | ormsgpack.OPT_SERIALIZE_NUMPY)
99
- b'\x84\xa4type\xa3job\xaacreated_at\xb91970-01-01T00:00:00+00:00\xa6status\xa4\xf0\x9f\x86\x97\xa7payload\x92\x92\x01\x02\x92\x03\x04'
100
- >>> ormsgpack.unpackb(_)
101
- {'type': 'job', 'created_at': '1970-01-01T00:00:00+00:00', 'status': '🆗', 'payload': [[1, 2], [3, 4]]}
102
- ```
103
-
104
- ### Serialize
105
-
106
- ```python
107
- def packb(
108
- __obj: Any,
109
- default: Optional[Callable[[Any], Any]] = ...,
110
- option: Optional[int] = ...,
111
- ) -> bytes: ...
112
- ```
113
-
114
- `packb()` serializes Python objects to msgpack.
115
-
116
- It natively serializes
117
- `bytes`, `str`, `dict`, `list`, `tuple`, `int`, `float`, `bool`,
118
- `dataclasses.dataclass`, `typing.TypedDict`, `datetime.datetime`,
119
- `datetime.date`, `datetime.time`, `uuid.UUID`, `numpy.ndarray`, and
120
- `None` instances. It supports arbitrary types through `default`. It
121
- serializes subclasses of `str`, `int`, `dict`, `list`,
122
- `dataclasses.dataclass`, and `enum.Enum`. It does not serialize subclasses
123
- of `tuple` to avoid serializing `namedtuple` objects as arrays.
124
-
125
- The output is a `bytes` object.
126
-
127
- The global interpreter lock (GIL) is held for the duration of the call.
128
-
129
- It raises `MsgpackEncodeError` on an unsupported type. This exception message
130
- describes the invalid object with the error message
131
- `Type is not msgpack serializable: ...`. To fix this, specify
132
- [default](#default).
133
-
134
- It raises `MsgpackEncodeError` on a `str` that contains invalid UTF-8.
135
-
136
- It raises `MsgpackEncodeError` if a `dict` has a key of a type other than `str` or `bytes`,
137
- unless `OPT_NON_STR_KEYS` is specified.
138
-
139
- It raises `MsgpackEncodeError` if the output of `default` recurses to handling by
140
- `default` more than 254 levels deep.
141
-
142
- It raises `MsgpackEncodeError` on circular references.
143
-
144
- It raises `MsgpackEncodeError` if a `tzinfo` on a datetime object is
145
- unsupported.
146
-
147
- `MsgpackEncodeError` is a subclass of `TypeError`.
148
-
149
- #### default
150
-
151
- To serialize a subclass or arbitrary types, specify `default` as a
152
- callable that returns a supported type. `default` may be a function,
153
- lambda, or callable class instance. To specify that a type was not
154
- handled by `default`, raise an exception such as `TypeError`.
155
-
156
- ```python
157
- >>> import ormsgpack, decimal
158
- >>> def default(obj):
159
- ... if isinstance(obj, decimal.Decimal):
160
- ... return str(obj)
161
- ... raise TypeError
162
- ...
163
- >>> ormsgpack.packb(decimal.Decimal("0.0842389659712649442845"))
164
- TypeError: Type is not msgpack serializable: decimal.Decimal
165
- >>> ormsgpack.packb(decimal.Decimal("0.0842389659712649442845"), default=default)
166
- b'\xb80.0842389659712649442845'
167
- >>> ormsgpack.packb({1, 2}, default=default)
168
- TypeError: Type is not msgpack serializable: set
169
- ```
170
-
171
- The `default` callable may return an object that itself
172
- must be handled by `default` up to 254 times before an exception
173
- is raised.
174
-
175
- It is important that `default` raise an exception if a type cannot be handled.
176
- Python otherwise implicitly returns `None`, which appears to the caller
177
- like a legitimate value and is serialized:
178
-
179
- ```python
180
- >>> import ormsgpack, decimal
181
- >>> def default(obj):
182
- ... if isinstance(obj, decimal.Decimal):
183
- ... return str(obj)
184
- ...
185
- >>> ormsgpack.packb({"set":{1, 2}}, default=default)
186
- b'\x81\xa3set\xc0'
187
- >>> ormsgpack.unpackb(_)
188
- {'set': None}
189
- ```
190
-
191
- To serialize a type as a MessagePack extension type, return an
192
- `ormsgpack.Ext` object. The instantiation arguments are an integer in
193
- the range `[0, 127]` and a `bytes` object, defining the type and
194
- value, respectively.
195
-
196
- ```python
197
- >>> import ormsgpack, decimal
198
- >>> def default(obj):
199
- ... if isinstance(obj, decimal.Decimal):
200
- ... return ormsgpack.Ext(0, str(obj).encode())
201
- ... raise TypeError
202
- ...
203
- >>> ormsgpack.packb(decimal.Decimal("0.0842389659712649442845"), default=default)
204
- b'\xc7\x18\x000.0842389659712649442845'
205
- ```
206
-
207
- `default` can also be used to serialize some supported types to a custom
208
- format by enabling the corresponding passthrough options.
209
-
210
- #### option
211
-
212
- To modify how data is serialized, specify `option`. Each `option` is an integer
213
- constant in `ormsgpack`. To specify multiple options, mask them together, e.g.,
214
- `option=ormsgpack.OPT_NON_STR_KEYS | ormsgpack.OPT_NAIVE_UTC`.
215
-
216
- ##### `OPT_NAIVE_UTC`
217
-
218
- Serialize `datetime.datetime` objects without a `tzinfo` and `numpy.datetime64`
219
- objects as UTC. This has no effect on `datetime.datetime` objects that have
220
- `tzinfo` set.
221
-
222
- ```python
223
- >>> import ormsgpack, datetime
224
- >>> ormsgpack.packb(
225
- ... datetime.datetime(1970, 1, 1, 0, 0, 0),
226
- ... )
227
- b'\xb31970-01-01T00:00:00'
228
- >>> ormsgpack.unpackb(_)
229
- '1970-01-01T00:00:00'
230
- >>> ormsgpack.packb(
231
- ... datetime.datetime(1970, 1, 1, 0, 0, 0),
232
- ... option=ormsgpack.OPT_NAIVE_UTC,
233
- ... )
234
- b'\xb91970-01-01T00:00:00+00:00'
235
- >>> ormsgpack.unpackb(_)
236
- '1970-01-01T00:00:00+00:00'
237
- ```
238
-
239
- ##### `OPT_NON_STR_KEYS`
240
-
241
- Serialize `dict` keys of type other than `str`. This allows `dict` keys
242
- to be one of `str`, `int`, `float`, `bool`, `None`, `datetime.datetime`,
243
- `datetime.date`, `datetime.time`, `enum.Enum`, and `uuid.UUID`.
244
- `dict` keys of unsupported types are not handled using `default` and
245
- result in `MsgpackEncodeError` being raised.
246
-
247
- ```python
248
- >>> import ormsgpack, datetime, uuid
249
- >>> ormsgpack.packb(
250
- ... {uuid.UUID("7202d115-7ff3-4c81-a7c1-2a1f067b1ece"): [1, 2, 3]},
251
- ... option=ormsgpack.OPT_NON_STR_KEYS,
252
- ... )
253
- b'\x81\xd9$7202d115-7ff3-4c81-a7c1-2a1f067b1ece\x93\x01\x02\x03'
254
- >>> ormsgpack.unpackb(_)
255
- {'7202d115-7ff3-4c81-a7c1-2a1f067b1ece': [1, 2, 3]}
256
- >>> ormsgpack.packb(
257
- ... {datetime.datetime(1970, 1, 1, 0, 0, 0): [1, 2, 3]},
258
- ... option=ormsgpack.OPT_NON_STR_KEYS | ormsgpack.OPT_NAIVE_UTC,
259
- ... )
260
- b'\x81\xb91970-01-01T00:00:00+00:00\x93\x01\x02\x03'
261
- >>> ormsgpack.unpackb(_)
262
- {'1970-01-01T00:00:00+00:00': [1, 2, 3]}
263
- ```
264
-
265
- These types are generally serialized how they would be as
266
- values, e.g., `datetime.datetime` is still an RFC 3339 string and respects
267
- options affecting it.
268
-
269
- This option has the risk of creating duplicate keys. This is because non-`str`
270
- objects may serialize to the same `str` as an existing key, e.g.,
271
- `{"1970-01-01T00:00:00+00:00": true, datetime.datetime(1970, 1, 1, 0, 0, 0): false}`.
272
- The last key to be inserted to the `dict` will be serialized last and a msgpack deserializer will presumably take the last
273
- occurrence of a key (in the above, `false`). The first value will be lost.
274
-
275
- This option is not compatible with `ormsgpack.OPT_SORT_KEYS`.
276
-
277
- ##### `OPT_OMIT_MICROSECONDS`
278
-
279
- Do not serialize the microsecond component of `datetime.datetime`,
280
- `datetime.time` and `numpy.datetime64` instances.
281
-
282
- ```python
283
- >>> import ormsgpack, datetime
284
- >>> ormsgpack.packb(
285
- ... datetime.datetime(1970, 1, 1, 0, 0, 0, 1),
286
- ... )
287
- b'\xba1970-01-01T00:00:00.000001'
288
- >>> ormsgpack.unpackb(_)
289
- '1970-01-01T00:00:00.000001'
290
- >>> ormsgpack.packb(
291
- ... datetime.datetime(1970, 1, 1, 0, 0, 0, 1),
292
- ... option=ormsgpack.OPT_OMIT_MICROSECONDS,
293
- ... )
294
- b'\xb31970-01-01T00:00:00'
295
- >>> ormsgpack.unpackb(_)
296
- '1970-01-01T00:00:00'
297
- ```
298
-
299
- ##### `OPT_PASSTHROUGH_BIG_INT`
300
-
301
- Enable passthrough of `int` instances smaller than -9223372036854775807 or
302
- larger than 18446744073709551615 to `default`.
303
-
304
- ```python
305
- >>> import ormsgpack
306
- >>> ormsgpack.packb(
307
- ... 2**65,
308
- ... )
309
- TypeError: Integer exceeds 64-bit range
310
- >>> ormsgpack.packb(
311
- ... 2**65,
312
- ... option=ormsgpack.OPT_PASSTHROUGH_BIG_INT,
313
- ... default=lambda _: {"type": "bigint", "value": str(_) }
314
- ... )
315
- b'\x82\xa4type\xa6bigint\xa5value\xb436893488147419103232'
316
- >>> ormsgpack.unpackb(_)
317
- {'type': 'bigint', 'value': '36893488147419103232'}
318
- ```
319
-
320
- ##### `OPT_PASSTHROUGH_DATACLASS`
321
-
322
- Enable passthrough of `dataclasses.dataclass` instances to `default`.
323
-
324
-
325
- ```python
326
- >>> import ormsgpack, dataclasses
327
- >>> @dataclasses.dataclass
328
- ... class User:
329
- ... id: str
330
- ... name: str
331
- ... password: str
332
- ...
333
- >>> def default(obj):
334
- ... if isinstance(obj, User):
335
- ... return {"id": obj.id, "name": obj.name}
336
- ... raise TypeError
337
- ...
338
- >>> ormsgpack.packb(User("3b1", "asd", "zxc"))
339
- b'\x83\xa2id\xa33b1\xa4name\xa3asd\xa8password\xa3zxc'
340
- >>> ormsgpack.packb(User("3b1", "asd", "zxc"), option=ormsgpack.OPT_PASSTHROUGH_DATACLASS)
341
- TypeError: Type is not msgpack serializable: User
342
- >>> ormsgpack.packb(
343
- ... User("3b1", "asd", "zxc"),
344
- ... option=ormsgpack.OPT_PASSTHROUGH_DATACLASS,
345
- ... default=default,
346
- ... )
347
- b'\x82\xa2id\xa33b1\xa4name\xa3asd'
348
- ```
349
-
350
- ##### `OPT_PASSTHROUGH_DATETIME`
351
-
352
- Enable passthrough of `datetime.datetime`, `datetime.date`, and
353
- `datetime.time` instances to `default`.
354
-
355
- ```python
356
- >>> import ormsgpack, datetime
357
- >>> def default(obj):
358
- ... if isinstance(obj, datetime.datetime):
359
- ... return obj.strftime("%a, %d %b %Y %H:%M:%S GMT")
360
- ... raise TypeError
361
- ...
362
- >>> ormsgpack.packb({"created_at": datetime.datetime(1970, 1, 1)})
363
- b'\x81\xaacreated_at\xb31970-01-01T00:00:00'
364
- >>> ormsgpack.packb({"created_at": datetime.datetime(1970, 1, 1)}, option=ormsgpack.OPT_PASSTHROUGH_DATETIME)
365
- TypeError: Type is not msgpack serializable: datetime.datetime
366
- >>> ormsgpack.packb(
367
- ... {"created_at": datetime.datetime(1970, 1, 1)},
368
- ... option=ormsgpack.OPT_PASSTHROUGH_DATETIME,
369
- ... default=default,
370
- ... )
371
- b'\x81\xaacreated_at\xbdThu, 01 Jan 1970 00:00:00 GMT'
372
- ```
373
-
374
- ##### `OPT_PASSTHROUGH_ENUM`
375
-
376
- Enable passthrough of `enum.Enum` instances to `default`.
377
-
378
- ##### `OPT_PASSTHROUGH_SUBCLASS`
379
-
380
- Enable passthrough of subclasses of `str`, `int`, `dict` and `list` to
381
- `default`.
382
-
383
- ```python
384
- >>> import ormsgpack
385
- >>> class Secret(str):
386
- ... pass
387
- ...
388
- >>> def default(obj):
389
- ... if isinstance(obj, Secret):
390
- ... return "******"
391
- ... raise TypeError
392
- ...
393
- >>> ormsgpack.packb(Secret("zxc"))
394
- b'\xa3zxc'
395
- >>> ormsgpack.packb(Secret("zxc"), option=ormsgpack.OPT_PASSTHROUGH_SUBCLASS)
396
- TypeError: Type is not msgpack serializable: Secret
397
- >>> ormsgpack.packb(Secret("zxc"), option=ormsgpack.OPT_PASSTHROUGH_SUBCLASS, default=default)
398
- b'\xa6******'
399
- ```
400
-
401
- ##### `OPT_PASSTHROUGH_TUPLE`
402
-
403
- Enable passthrough of `tuple` instances to `default`.
404
-
405
- ```python
406
- >>> import ormsgpack
407
- >>> ormsgpack.packb(
408
- ... (9193, "test", 42),
409
- ... )
410
- b'\x93\xcd#\xe9\xa4test*'
411
- >>> ormsgpack.unpackb(_)
412
- [9193, 'test', 42]
413
- >>> ormsgpack.packb(
414
- ... (9193, "test", 42),
415
- ... option=ormsgpack.OPT_PASSTHROUGH_TUPLE,
416
- ... default=lambda _: {"type": "tuple", "value": list(_)}
417
- ... )
418
- b'\x82\xa4type\xa5tuple\xa5value\x93\xcd#\xe9\xa4test*'
419
- >>> ormsgpack.unpackb(_)
420
- {'type': 'tuple', 'value': [9193, 'test', 42]}
421
- ```
422
-
423
- ##### `OPT_PASSTHROUGH_UUID`
424
-
425
- Enable passthrough of `uuid.UUID` instances to `default`.
426
-
427
- ##### `OPT_SERIALIZE_NUMPY`
428
-
429
- Serialize `numpy.ndarray` instances. For more, see
430
- [numpy](#numpy).
431
-
432
- ##### `OPT_SERIALIZE_PYDANTIC`
433
- Serialize `pydantic.BaseModel` instances.
434
-
435
- ##### `OPT_SORT_KEYS`
436
-
437
- Serialize `dict` keys and pydantic model fields in sorted order. The default
438
- is to serialize in an unspecified order.
439
-
440
- This can be used to ensure the order is deterministic for hashing or tests.
441
- It has a substantial performance penalty and is not recommended in general.
442
-
443
- ```python
444
- >>> import ormsgpack
445
- >>> ormsgpack.packb({"b": 1, "c": 2, "a": 3})
446
- b'\x83\xa1b\x01\xa1c\x02\xa1a\x03'
447
- >>> ormsgpack.packb({"b": 1, "c": 2, "a": 3}, option=ormsgpack.OPT_SORT_KEYS)
448
- b'\x83\xa1a\x03\xa1b\x01\xa1c\x02'
449
- ```
450
-
451
- The sorting is not collation/locale-aware:
452
-
453
- ```python
454
- >>> import ormsgpack
455
- >>> ormsgpack.packb({"a": 1, "ä": 2, "A": 3}, option=ormsgpack.OPT_SORT_KEYS)
456
- b'\x83\xa1A\x03\xa1a\x01\xa2\xc3\xa4\x02'
457
- ```
458
-
459
- `dataclass` also serialize as maps but this has no effect on them.
460
-
461
- ##### `OPT_UTC_Z`
462
-
463
- Serialize a UTC timezone on `datetime.datetime` and `numpy.datetime64` instances
464
- as `Z` instead of `+00:00`.
465
-
466
- ```python
467
- >>> import ormsgpack, datetime
468
- >>> ormsgpack.packb(
469
- ... datetime.datetime(1970, 1, 1, 0, 0, 0, tzinfo=datetime.timezone.utc),
470
- ... )
471
- b'\xb91970-01-01T00:00:00+00:00'
472
- >>> ormsgpack.packb(
473
- ... datetime.datetime(1970, 1, 1, 0, 0, 0, tzinfo=datetime.timezone.utc),
474
- ... option=ormsgpack.OPT_UTC_Z
475
- ... )
476
- b'\xb41970-01-01T00:00:00Z'
477
- ```
478
-
479
- ### Deserialize
480
- ```python
481
- def unpackb(
482
- __obj: Union[bytes, bytearray, memoryview],
483
- /,
484
- ext_hook: Optional[Callable[[int, bytes], Any]] = ...,
485
- option: Optional[int] = ...,
486
- ) -> Any: ...
487
- ```
488
-
489
- `unpackb()` deserializes msgpack to Python objects. It deserializes to `dict`,
490
- `list`, `int`, `float`, `str`, `bool`, `bytes` and `None` objects.
491
-
492
- `bytes`, `bytearray`, `memoryview` input are accepted.
493
-
494
- ormsgpack maintains a cache of map keys for the duration of the process. This
495
- causes a net reduction in memory usage by avoiding duplicate strings. The
496
- keys must be at most 64 bytes to be cached and 512 entries are stored.
497
-
498
- The global interpreter lock (GIL) is held for the duration of the call.
499
-
500
- It raises `MsgpackDecodeError` if given an invalid type or invalid
501
- msgpack.
502
-
503
- `MsgpackDecodeError` is a subclass of `ValueError`.
504
-
505
- #### ext_hook
506
-
507
- To deserialize extension types, specify the optional `ext_hook`
508
- argument. The value should be a callable and is invoked with the
509
- extension type and value as arguments.
510
-
511
- ```python
512
- >>> import ormsgpack, decimal
513
- >>> def ext_hook(tag, data):
514
- ... if tag == 0:
515
- ... return decimal.Decimal(data.decode())
516
- ... raise TypeError
517
- ...
518
- >>> ormsgpack.packb(
519
- ... ormsgpack.Ext(0, str(decimal.Decimal("0.0842389659712649442845")).encode())
520
- ... )
521
- b'\xc7\x18\x000.0842389659712649442845'
522
- >>> ormsgpack.unpackb(_, ext_hook=ext_hook)
523
- Decimal('0.0842389659712649442845'
524
- ```
525
-
526
- #### option
527
- `unpackb()` supports the `OPT_NON_STR_KEYS` option, that is similar to original msgpack's `strict_map_key=False`.
528
- Be aware that this option is considered unsafe and disabled by default in msgpack due to possibility of HashDoS.
529
-
530
- ## Types
531
-
532
- ### dataclass
533
-
534
- ormsgpack serializes instances of `dataclasses.dataclass` natively. It serializes
535
- instances 40-50x as fast as other libraries and avoids a severe slowdown seen
536
- in other libraries compared to serializing `dict`.
537
-
538
- It is supported to pass all variants of dataclasses, including dataclasses
539
- using `__slots__`, frozen dataclasses, those with optional or default
540
- attributes, and subclasses. There is a performance benefit to not
541
- using `__slots__`.
542
-
543
- Dataclasses are serialized as maps, with every attribute serialized and in
544
- the order given on class definition:
545
-
546
- ```python
547
- >>> import dataclasses, ormsgpack, typing
548
- >>> @dataclasses.dataclass
549
- ... class Member:
550
- ... id: int
551
- ... active: bool = dataclasses.field(default=False)
552
- ...
553
- >>> @dataclasses.dataclass
554
- ... class Object:
555
- ... id: int
556
- ... name: str
557
- ... members: typing.List[Member]
558
- ...
559
- >>> ormsgpack.packb(Object(1, "a", [Member(1, True), Member(2)]))
560
- b'\x83\xa2id\x01\xa4name\xa1a\xa7members\x92\x82\xa2id\x01\xa6active\xc3\x82\xa2id\x02\xa6active\xc2'
561
- ```
562
- #### Performance
563
- ![alt text](doc/dataclass.svg "dataclass")
564
-
565
- ```
566
- --------------------------------------------------------------------------------- benchmark 'dataclass': 2 tests --------------------------------------------------------------------------------
567
- Name (time in ms) Min Max Mean StdDev Median IQR Outliers OPS Rounds Iterations
568
- -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
569
- test_dataclass_ormsgpack 3.4248 (1.0) 7.7949 (1.0) 3.6266 (1.0) 0.3293 (1.0) 3.5815 (1.0) 0.0310 (1.0) 4;34 275.7434 (1.0) 240 1
570
- test_dataclass_msgpack 140.2774 (40.96) 143.6087 (18.42) 141.3847 (38.99) 1.0038 (3.05) 141.1823 (39.42) 0.7304 (23.60) 2;1 7.0729 (0.03) 8 1
571
- -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
572
- ```
573
-
574
- ### datetime
575
-
576
- ormsgpack serializes `datetime.datetime` objects to
577
- [RFC 3339](https://tools.ietf.org/html/rfc3339) format,
578
- e.g., "1970-01-01T00:00:00+00:00". This is a subset of ISO 8601 and is
579
- compatible with `isoformat()` in the standard library.
580
-
581
- ```python
582
- >>> import ormsgpack, datetime, zoneinfo
583
- >>> ormsgpack.packb(
584
- ... datetime.datetime(2018, 12, 1, 2, 3, 4, 9, tzinfo=zoneinfo.ZoneInfo('Australia/Adelaide'))
585
- ... )
586
- b'\xd9 2018-12-01T02:03:04.000009+10:30'
587
- >>> ormsgpack.unpackb(_)
588
- '2018-12-01T02:03:04.000009+10:30'
589
- >>> ormsgpack.packb(
590
- ... datetime.datetime.fromtimestamp(4123518902).replace(tzinfo=datetime.timezone.utc)
591
- ... )
592
- b'\xb92100-09-02T00:55:02+00:00'
593
- >>> ormsgpack.unpackb(_)
594
- '2100-09-02T00:55:02+00:00'
595
- >>> ormsgpack.packb(
596
- ... datetime.datetime.fromtimestamp(4123518902)
597
- ... )
598
- b'\xb32100-09-02T00:55:02'
599
- >>> ormsgpack.unpackb(_)
600
- '2100-09-02T00:55:02'
601
- ```
602
-
603
- `datetime.datetime` supports instances with a `tzinfo` that is `None`,
604
- `datetime.timezone.utc`, a timezone instance from the python3.9+ `zoneinfo`
605
- module, or a timezone instance from the third-party `pendulum`, `pytz`, or
606
- `dateutil`/`arrow` libraries.
607
-
608
- `datetime.time` objects must not have a `tzinfo`.
609
-
610
- ```python
611
- >>> import ormsgpack, datetime
612
- >>> ormsgpack.packb(datetime.time(12, 0, 15, 290))
613
- b'\xaf12:00:15.000290'
614
- >>> ormsgpack.unpackb(_)
615
- '12:00:15.000290'
616
- ```
617
-
618
- `datetime.date` objects will always serialize.
619
-
620
- ```python
621
- >>> import ormsgpack, datetime
622
- >>> ormsgpack.packb(datetime.date(1900, 1, 2))
623
- b'\xaa1900-01-02'
624
- >>> ormsgpack.unpackb(_)
625
- '1900-01-02'
626
- ```
627
-
628
- Errors with `tzinfo` result in `MsgpackEncodeError` being raised.
629
-
630
- To use "Z" suffix instead of "+00:00" to indicate UTC ("Zulu") time, use the option
631
- `ormsgpack.OPT_UTC_Z`.
632
-
633
- To assume datetimes without timezone are UTC, use the option `ormsgpack.OPT_NAIVE_UTC`.
634
-
635
- ### enum
636
-
637
- ormsgpack serializes enums natively. Options apply to their values.
638
-
639
- ```python
640
- >>> import enum, datetime, ormsgpack
641
- >>> class DatetimeEnum(enum.Enum):
642
- ... EPOCH = datetime.datetime(1970, 1, 1, 0, 0, 0)
643
- ...
644
- >>> ormsgpack.packb(DatetimeEnum.EPOCH)
645
- b'\xb31970-01-01T00:00:00'
646
- >>> ormsgpack.unpackb(_)
647
- '1970-01-01T00:00:00'
648
- >>> ormsgpack.packb(DatetimeEnum.EPOCH, option=ormsgpack.OPT_NAIVE_UTC)
649
- b'\xb91970-01-01T00:00:00+00:00'
650
- >>> ormsgpack.unpackb(_)
651
- '1970-01-01T00:00:00+00:00'
652
- ```
653
-
654
- Enums with members that are not supported types can be serialized using
655
- `default`:
656
-
657
- ```python
658
- >>> import enum, ormsgpack
659
- >>> class Custom:
660
- ... def __init__(self, val):
661
- ... self.val = val
662
- ...
663
- >>> def default(obj):
664
- ... if isinstance(obj, Custom):
665
- ... return obj.val
666
- ... raise TypeError
667
- ...
668
- >>> class CustomEnum(enum.Enum):
669
- ... ONE = Custom(1)
670
- ...
671
- >>> ormsgpack.packb(CustomEnum.ONE, default=default)
672
- b'\x01'
673
- >>> ormsgpack.unpackb(_)
674
- 1
675
- ```
676
-
677
- ### float
678
-
679
- ormsgpack serializes and deserializes double precision floats with no loss of
680
- precision and consistent rounding.
681
-
682
- ### int
683
-
684
- ormsgpack serializes and deserializes 64-bit integers by default. The range
685
- supported is a signed 64-bit integer's minimum (-9223372036854775807) to
686
- an unsigned 64-bit integer's maximum (18446744073709551615).
687
-
688
- ### numpy
689
-
690
- ormsgpack natively serializes `numpy.ndarray` and individual
691
- `numpy.float64`, `numpy.float32`, `numpy.float16`,
692
- `numpy.int64`, `numpy.int32`, `numpy.int16`, `numpy.int8`,
693
- `numpy.uint64`, `numpy.uint32`, `numpy.uint16`, `numpy.uint8`,
694
- `numpy.uintp`, `numpy.intp`, `numpy.datetime64`, and `numpy.bool`
695
- instances.
696
-
697
- `numpy.datetime64` instances are serialized as RFC 3339 strings.
698
-
699
- ormsgpack is faster than all compared libraries at serializing
700
- numpy instances. Serializing numpy data requires specifying
701
- `option=ormsgpack.OPT_SERIALIZE_NUMPY`.
702
-
703
- ```python
704
- >>> import ormsgpack, numpy
705
- >>> ormsgpack.packb(
706
- ... numpy.array([[1, 2, 3], [4, 5, 6]]),
707
- ... option=ormsgpack.OPT_SERIALIZE_NUMPY,
708
- ... )
709
- b'\x92\x93\x01\x02\x03\x93\x04\x05\x06'
710
- >>> ormsgpack.unpackb(_)
711
- [[1, 2, 3], [4, 5, 6]]
712
- ```
713
-
714
- The array must be a contiguous C array (`C_CONTIGUOUS`) and one of the
715
- supported datatypes.
716
-
717
- If an array is not a contiguous C array or contains an supported datatype,
718
- ormsgpack falls through to `default`. In `default`, `obj.tolist()` can be
719
- specified. If an array is malformed, which is not expected,
720
- `ormsgpack.MsgpackEncodeError` is raised.
721
-
722
- #### Performance
723
- ![alt text](doc/numpy_float64.svg "numpy")
724
- ![alt text](doc/numpy_int8.svg "numpy int8")
725
- ![alt text](doc/numpy_int32.svg "numpy int32")
726
- ![alt text](doc/numpy_npbool.svg "numpy npbool")
727
- ![alt text](doc/numpy_uint8.svg "numpy uint8")
728
- ```
729
- ---------------------------------------------------------------------------------- benchmark 'numpy float64': 2 tests ---------------------------------------------------------------------------------
730
- Name (time in ms) Min Max Mean StdDev Median IQR Outliers OPS Rounds Iterations
731
- -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
732
- test_numpy_ormsgpack[float64] 77.9625 (1.0) 85.2507 (1.0) 79.0326 (1.0) 1.9043 (1.0) 78.5505 (1.0) 0.7408 (1.0) 1;1 12.6530 (1.0) 13 1
733
- test_numpy_msgpack[float64] 511.5176 (6.56) 606.9395 (7.12) 559.0017 (7.07) 44.0661 (23.14) 572.5499 (7.29) 81.2972 (109.75) 3;0 1.7889 (0.14) 5 1
734
- -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
735
-
736
-
737
- ------------------------------------------------------------------------------------- benchmark 'numpy int32': 2 tests -------------------------------------------------------------------------------------
738
- Name (time in ms) Min Max Mean StdDev Median IQR Outliers OPS Rounds Iterations
739
- ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
740
- test_numpy_ormsgpack[int32] 197.8751 (1.0) 210.3111 (1.0) 201.1033 (1.0) 5.1886 (1.0) 198.8518 (1.0) 3.8297 (1.0) 1;1 4.9726 (1.0) 5 1
741
- test_numpy_msgpack[int32] 1,363.8515 (6.89) 1,505.4747 (7.16) 1,428.2127 (7.10) 53.4176 (10.30) 1,425.3516 (7.17) 72.8064 (19.01) 2;0 0.7002 (0.14) 5 1
742
- ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
743
-
744
-
745
- -------------------------------------------------------------------------------- benchmark 'numpy int8': 2 tests ---------------------------------------------------------------------------------
746
- Name (time in ms) Min Max Mean StdDev Median IQR Outliers OPS Rounds Iterations
747
- --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
748
- test_numpy_ormsgpack[int8] 107.8013 (1.0) 113.7336 (1.0) 109.0364 (1.0) 1.7805 (1.0) 108.3574 (1.0) 0.4066 (1.0) 1;2 9.1712 (1.0) 10 1
749
- test_numpy_msgpack[int8] 685.4149 (6.36) 703.2958 (6.18) 693.2396 (6.36) 7.9572 (4.47) 691.5435 (6.38) 14.4142 (35.45) 1;0 1.4425 (0.16) 5 1
750
- --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
751
-
752
-
753
- ------------------------------------------------------------------------------------- benchmark 'numpy npbool': 2 tests --------------------------------------------------------------------------------------
754
- Name (time in ms) Min Max Mean StdDev Median IQR Outliers OPS Rounds Iterations
755
- --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
756
- test_numpy_ormsgpack[npbool] 87.9005 (1.0) 89.5460 (1.0) 88.7928 (1.0) 0.5098 (1.0) 88.8508 (1.0) 0.6609 (1.0) 4;0 11.2622 (1.0) 12 1
757
- test_numpy_msgpack[npbool] 1,095.0599 (12.46) 1,176.3442 (13.14) 1,120.5916 (12.62) 32.9993 (64.73) 1,110.4216 (12.50) 38.4189 (58.13) 1;0 0.8924 (0.08) 5 1
758
- --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
759
-
760
-
761
- --------------------------------------------------------------------------------- benchmark 'numpy uint8': 2 tests ---------------------------------------------------------------------------------
762
- Name (time in ms) Min Max Mean StdDev Median IQR Outliers OPS Rounds Iterations
763
- ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
764
- test_numpy_ormsgpack[uint8] 133.1743 (1.0) 134.7246 (1.0) 134.2793 (1.0) 0.4946 (1.0) 134.3120 (1.0) 0.4492 (1.0) 1;1 7.4472 (1.0) 8 1
765
- test_numpy_msgpack[uint8] 727.1393 (5.46) 824.8247 (6.12) 775.7032 (5.78) 34.9887 (70.73) 775.9595 (5.78) 36.2824 (80.78) 2;0 1.2892 (0.17) 5 1
766
- ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
767
- ```
768
-
769
- ### uuid
770
-
771
- ormsgpack serializes `uuid.UUID` instances to
772
- [RFC 4122](https://tools.ietf.org/html/rfc4122) format, e.g.,
773
- "f81d4fae-7dec-11d0-a765-00a0c91e6bf6".
774
-
775
- ```python
776
- >>> import ormsgpack, uuid
777
- >>> ormsgpack.packb(uuid.UUID('f81d4fae-7dec-11d0-a765-00a0c91e6bf6'))
778
- b'\xd9$f81d4fae-7dec-11d0-a765-00a0c91e6bf6'
779
- >>> ormsgpack.unpackb(_)
780
- 'f81d4fae-7dec-11d0-a765-00a0c91e6bf6'
781
- >>> ormsgpack.packb(uuid.uuid5(uuid.NAMESPACE_DNS, "python.org"))
782
- b'\xd9$886313e1-3b8a-5372-9b90-0c9aee199e5d'
783
- >>> ormsgpack.unpackb(_)
784
- '886313e1-3b8a-5372-9b90-0c9aee199e5d
785
- ```
786
-
787
- ### Pydantic
788
- ormsgpack serializes `pydantic.BaseModel` instances natively, with
789
- [duck-typing](https://docs.pydantic.dev/2.10/concepts/serialization/#serializing-with-duck-typing).
790
- This is equivalent to serializing
791
- `model.model_dump(serialize_as_any=True)` with Pydantic V2 or
792
- `model.dict()`with Pydantic V1.
793
-
794
- #### Performance
795
- ![alt text](doc/pydantic.svg "pydantic")
796
-
797
- ```
798
- -------------------------------------------------------------------------------- benchmark 'pydantic': 2 tests ---------------------------------------------------------------------------------
799
- Name (time in ms) Min Max Mean StdDev Median IQR Outliers OPS Rounds Iterations
800
- ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
801
- test_pydantic_ormsgpack 4.3918 (1.0) 12.6521 (1.0) 4.8550 (1.0) 1.1455 (3.98) 4.6101 (1.0) 0.0662 (1.0) 11;24 205.9727 (1.0) 204 1
802
- test_pydantic_msgpack 124.5500 (28.36) 125.5427 (9.92) 125.0582 (25.76) 0.2877 (1.0) 125.0855 (27.13) 0.2543 (3.84) 2;0 7.9963 (0.04) 8 1
803
- ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
804
- ```
805
-
806
- ## Latency
807
- ### Graphs
808
- ![alt text](doc/twitter_packb.svg "twitter.json serialization")
809
- ![alt text](doc/twitter_unpackb.svg "twitter.json deserialization")
810
- ![alt text](doc/github_packb.svg "github.json serialization")
811
- ![alt text](doc/github_unpackb.svg "github.json deserialization")
812
- ![alt text](doc/citm_catalog_packb.svg "citm_catalog.json serialization")
813
- ![alt text](doc/citm_catalog_unpackb.svg "citm_catalog.json deserialization")
814
- ![alt text](doc/canada_packb.svg "canada.json serialization")
815
- ![alt text](doc/canada_unpackb.svg "canada.json deserialization")
816
- ### Data
817
- ```
818
- ----------------------------------------------------------------------------- benchmark 'canada packb': 2 tests ------------------------------------------------------------------------------
819
- Name (time in ms) Min Max Mean StdDev Median IQR Outliers OPS Rounds Iterations
820
- ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
821
- test_ormsgpack_packb[canada] 3.5302 (1.0) 3.8939 (1.0) 3.7319 (1.0) 0.0563 (1.0) 3.7395 (1.0) 0.0484 (1.0) 56;22 267.9571 (1.0) 241 1
822
- test_msgpack_packb[canada] 8.8642 (2.51) 14.0432 (3.61) 9.3660 (2.51) 0.5649 (10.03) 9.2983 (2.49) 0.0982 (2.03) 3;11 106.7691 (0.40) 106 1
823
- ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
824
-
825
-
826
- ------------------------------------------------------------------------------- benchmark 'canada unpackb': 2 tests --------------------------------------------------------------------------------
827
- Name (time in ms) Min Max Mean StdDev Median IQR Outliers OPS Rounds Iterations
828
- ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
829
- test_msgpack_unpackb[canada] 10.1176 (1.0) 62.0466 (1.18) 33.4806 (1.0) 18.8279 (1.0) 46.6582 (1.0) 38.5921 (1.02) 30;0 29.8680 (1.0) 67 1
830
- test_ormsgpack_unpackb[canada] 11.3992 (1.13) 52.6587 (1.0) 34.1842 (1.02) 18.9461 (1.01) 47.6456 (1.02) 37.8024 (1.0) 8;0 29.2533 (0.98) 20 1
831
- ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
832
-
833
-
834
- ----------------------------------------------------------------------------- benchmark 'citm_catalog packb': 2 tests -----------------------------------------------------------------------------
835
- Name (time in ms) Min Max Mean StdDev Median IQR Outliers OPS Rounds Iterations
836
- ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
837
- test_ormsgpack_packb[citm_catalog] 1.8024 (1.0) 2.1259 (1.0) 1.9487 (1.0) 0.0346 (1.0) 1.9525 (1.0) 0.0219 (1.0) 79;60 513.1650 (1.0) 454 1
838
- test_msgpack_packb[citm_catalog] 3.4195 (1.90) 3.8128 (1.79) 3.6928 (1.90) 0.0535 (1.55) 3.7009 (1.90) 0.0250 (1.14) 47;49 270.7958 (0.53) 257 1
839
- ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
840
-
841
-
842
- ------------------------------------------------------------------------------ benchmark 'citm_catalog unpackb': 2 tests ------------------------------------------------------------------------------
843
- Name (time in ms) Min Max Mean StdDev Median IQR Outliers OPS Rounds Iterations
844
- -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
845
- test_ormsgpack_unpackb[citm_catalog] 5.6986 (1.0) 46.1843 (1.0) 14.2491 (1.0) 15.9791 (1.0) 6.1051 (1.0) 0.3074 (1.0) 5;5 70.1798 (1.0) 23 1
846
- test_msgpack_unpackb[citm_catalog] 7.2600 (1.27) 56.6642 (1.23) 16.4095 (1.15) 16.3257 (1.02) 7.7364 (1.27) 0.4944 (1.61) 28;29 60.9404 (0.87) 125 1
847
- -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
848
-
849
-
850
- ----------------------------------------------------------------------------------- benchmark 'github packb': 2 tests -----------------------------------------------------------------------------------
851
- Name (time in us) Min Max Mean StdDev Median IQR Outliers OPS (Kops/s) Rounds Iterations
852
- ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
853
- test_ormsgpack_packb[github] 73.0000 (1.0) 215.9000 (1.0) 80.4826 (1.0) 4.8889 (1.0) 80.3000 (1.0) 1.1000 (1.83) 866;1118 12.4250 (1.0) 6196 1
854
- test_msgpack_packb[github] 103.8000 (1.42) 220.8000 (1.02) 112.8049 (1.40) 4.9686 (1.02) 113.0000 (1.41) 0.6000 (1.0) 1306;1560 8.8649 (0.71) 7028 1
855
- ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
856
-
857
-
858
- ----------------------------------------------------------------------------------- benchmark 'github unpackb': 2 tests -----------------------------------------------------------------------------------
859
- Name (time in us) Min Max Mean StdDev Median IQR Outliers OPS (Kops/s) Rounds Iterations
860
- -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
861
- test_ormsgpack_unpackb[github] 201.3000 (1.0) 318.5000 (1.0) 219.0861 (1.0) 6.7340 (1.0) 219.1000 (1.0) 1.2000 (1.0) 483;721 4.5644 (1.0) 3488 1
862
- test_msgpack_unpackb[github] 289.8000 (1.44) 436.0000 (1.37) 314.9631 (1.44) 9.4130 (1.40) 315.1000 (1.44) 2.3000 (1.92) 341;557 3.1750 (0.70) 2477 1
863
- -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
864
-
865
- --------------------------------------------------------------------------------------- benchmark 'twitter packb': 2 tests ---------------------------------------------------------------------------------------
866
- Name (time in us) Min Max Mean StdDev Median IQR Outliers OPS Rounds Iterations
867
- ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
868
- test_ormsgpack_packb[twitter] 820.7000 (1.0) 2,945.2000 (2.03) 889.3791 (1.0) 78.4139 (2.43) 884.2000 (1.0) 12.5250 (1.0) 4;76 1,124.3799 (1.0) 809 1
869
- test_msgpack_packb[twitter] 1,209.3000 (1.47) 1,451.2000 (1.0) 1,301.3615 (1.46) 32.2147 (1.0) 1,306.7000 (1.48) 14.1000 (1.13) 118;138 768.4260 (0.68) 592 1
870
- ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
871
-
872
-
873
- ------------------------------------------------------------------------------ benchmark 'twitter unpackb': 2 tests -----------------------------------------------------------------------------
874
- Name (time in ms) Min Max Mean StdDev Median IQR Outliers OPS Rounds Iterations
875
- -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
876
- test_ormsgpack_unpackb[twitter] 2.7097 (1.0) 41.1530 (1.0) 3.2721 (1.0) 3.5860 (1.03) 2.8868 (1.0) 0.0614 (1.32) 4;38 305.6098 (1.0) 314 1
877
- test_msgpack_unpackb[twitter] 3.8079 (1.41) 42.0617 (1.02) 4.4459 (1.36) 3.4893 (1.0) 4.1097 (1.42) 0.0465 (1.0) 2;54 224.9267 (0.74) 228 1
878
- -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
879
- ```
880
- ### Reproducing
881
-
882
- The above was measured using Python 3.7.9 on Azure Linux VM (x86_64) with ormsgpack 0.2.1 and msgpack 1.0.2.
883
-
884
- The latency results can be reproduced using `./scripts/benchmark.sh` and graphs using
885
- `pytest --benchmark-histogram benchmarks/bench_*`.
886
- ## Questions
887
-
888
- ### Why can't I install it from PyPI?
889
-
890
- Probably `pip` needs to be upgraded to version 20.3 or later to support
891
- the latest manylinux_x_y or universal2 wheel formats.
892
-
893
- ### Will it deserialize to dataclasses, UUIDs, decimals, etc or support object_hook?
894
-
895
- No. This requires a schema specifying what types are expected and how to
896
- handle errors etc. This is addressed by data validation libraries a
897
- level above this.
898
-
899
- ## Packaging
900
-
901
- To package ormsgpack requires [Rust](https://www.rust-lang.org/) 1.81
902
- or newer and the [maturin](https://github.com/PyO3/maturin) build
903
- tool. The default feature `unstable-simd` enables the usage of SIMD
904
- operations and requires nightly Rust. The recommended build command
905
- is:
906
-
907
- ```sh
908
- maturin build --release --strip
909
- ```
910
-
911
- ormsgpack is tested on Linux/amd64, Linux/aarch64, Linux/armv7, macOS/amd64 and Windows/amd64.
912
-
913
- There are no runtime dependencies other than libc.
914
-
915
- ## License
916
-
917
- orjson was written by ijl <<ijl@mailbox.org>>, copyright 2018 - 2021, licensed
918
- under both the Apache 2 and MIT licenses.
919
-
920
- ormsgpack was forked from orjson by Aviram Hassan and is now maintained by Emanuele Giaquinta (@exg), licensed
921
- same as orjson.
922
-
@@ -1,12 +0,0 @@
1
- ormsgpack-1.9.1.dist-info/METADATA,sha256=s0leAev2Z_6AFf59hQ8tjzLgexZLuAM1htuSLMYxQIY,44361
2
- ormsgpack-1.9.1.dist-info/WHEEL,sha256=mDFV3bKFgwlxLHvOsPqpR9up9dUKYzsUQNKBdkW5c08,94
3
- ormsgpack-1.9.1.dist-info/entry_points.txt,sha256=b4bGmxqo1PPqO42Cjz2A2X4Gy4h1PCoOygCzeS-m22I,63
4
- ormsgpack-1.9.1.dist-info/licenses/LICENSE-APACHE,sha256=fP1zjFPWHHnwfjSPYiv3cHyQhCNwVNN_vgd4inX1iBw,11048
5
- ormsgpack-1.9.1.dist-info/licenses/LICENSE-MIT,sha256=NlFq79yExdWh50hUJZE6ItvaaesZMMXoTWrklytRlLk,1046
6
- ormsgpack/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
7
- ormsgpack/_pyinstaller/hook-ormsgpack.py,sha256=Bj3rdqNTDG_uR-qYnGA0GHiKshhyBrdY_xlyc0hTD_Q,118
8
- ormsgpack/_pyinstaller/__init__.py,sha256=PiSpvMUWta2R2gVSfAut2h3Vtw9saEyF92GjC4h293E,140
9
- ormsgpack/__init__.py,sha256=71z0yVisd9vXd53nMWrDPz3zT5KM535N7XSGZeDXDQg,1081
10
- ormsgpack/__init__.pyi,sha256=m367J44MWhEgP0-R5l2clxqQsw7BJdtbz8oSdyVe4fQ,905
11
- ormsgpack/ormsgpack.cp39-win_amd64.pyd,sha256=ZNw8eVQjNVho6w7FVCN0PBYCrD9bkN8wHV-ngm6lkvI,214528
12
- ormsgpack-1.9.1.dist-info/RECORD,,