ormsgpack 1.4.1__cp39-none-win_amd64.whl → 1.5.0__cp39-none-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,7 +1,25 @@
1
1
  # SPDX-License-Identifier: (Apache-2.0 OR MIT)
2
2
 
3
- from .ormsgpack import *
4
- from .ormsgpack import __version__
3
+ from .ormsgpack import (
4
+ OPT_NAIVE_UTC,
5
+ OPT_NON_STR_KEYS,
6
+ OPT_OMIT_MICROSECONDS,
7
+ OPT_PASSTHROUGH_BIG_INT,
8
+ OPT_PASSTHROUGH_DATACLASS,
9
+ OPT_PASSTHROUGH_DATETIME,
10
+ OPT_PASSTHROUGH_SUBCLASS,
11
+ OPT_PASSTHROUGH_TUPLE,
12
+ OPT_SERIALIZE_NUMPY,
13
+ OPT_SERIALIZE_PYDANTIC,
14
+ OPT_SORT_KEYS,
15
+ OPT_UTC_Z,
16
+ Ext,
17
+ MsgpackDecodeError,
18
+ MsgpackEncodeError,
19
+ __version__,
20
+ packb,
21
+ unpackb,
22
+ )
5
23
 
6
24
  __all__ = (
7
25
  "__version__",
@@ -13,7 +31,7 @@ __all__ = (
13
31
  "OPT_NAIVE_UTC",
14
32
  "OPT_NON_STR_KEYS",
15
33
  "OPT_OMIT_MICROSECONDS",
16
- "OPT_PASSTHROUGH_BIGINT",
34
+ "OPT_PASSTHROUGH_BIG_INT",
17
35
  "OPT_PASSTHROUGH_DATACLASS",
18
36
  "OPT_PASSTHROUGH_DATETIME",
19
37
  "OPT_PASSTHROUGH_SUBCLASS",
Binary file
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.3
2
2
  Name: ormsgpack
3
- Version: 1.4.1
3
+ Version: 1.5.0
4
4
  Classifier: Development Status :: 5 - Production/Stable
5
5
  Classifier: Intended Audience :: Developers
6
6
  Classifier: License :: OSI Approved :: Apache Software License
@@ -91,13 +91,10 @@ available in the repository.
91
91
  To install a wheel from PyPI:
92
92
 
93
93
  ```sh
94
- pip install --upgrade "pip>=19.3" # manylinux2014 support
94
+ pip install --upgrade "pip>=20.3" # manylinux_x_y, universal2 wheel support
95
95
  pip install --upgrade ormsgpack
96
96
  ```
97
97
 
98
- Notice that Linux environments with a `pip` version shipped in 2018 or earlier
99
- must first upgrade `pip` to support `manylinux2014` wheels.
100
-
101
98
  To build a wheel, see [packaging](#packaging).
102
99
 
103
100
  ### Quickstart
@@ -107,11 +104,11 @@ This is an example of serializing, with options specified, and deserializing:
107
104
  ```python
108
105
  >>> import ormsgpack, datetime, numpy
109
106
  >>> data = {
110
- "type": "job",
111
- "created_at": datetime.datetime(1970, 1, 1),
112
- "status": "🆗",
113
- "payload": numpy.array([[1, 2], [3, 4]]),
114
- }
107
+ ... "type": "job",
108
+ ... "created_at": datetime.datetime(1970, 1, 1),
109
+ ... "status": "🆗",
110
+ ... "payload": numpy.array([[1, 2], [3, 4]]),
111
+ ... }
115
112
  >>> ormsgpack.packb(data, option=ormsgpack.OPT_NAIVE_UTC | ormsgpack.OPT_SERIALIZE_NUMPY)
116
113
  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'
117
114
  >>> ormsgpack.unpackb(_)
@@ -173,18 +170,17 @@ handled by `default`, raise an exception such as `TypeError`.
173
170
 
174
171
  ```python
175
172
  >>> import ormsgpack, decimal
176
- >>>
177
- def default(obj):
178
- if isinstance(obj, decimal.Decimal):
179
- return str(obj)
180
- raise TypeError
181
-
173
+ >>> def default(obj):
174
+ ... if isinstance(obj, decimal.Decimal):
175
+ ... return str(obj)
176
+ ... raise TypeError
177
+ ...
182
178
  >>> ormsgpack.packb(decimal.Decimal("0.0842389659712649442845"))
183
- MsgpackEncodeError: Type is not msgpack serializable: decimal.Decimal
179
+ TypeError: Type is not msgpack serializable: decimal.Decimal
184
180
  >>> ormsgpack.packb(decimal.Decimal("0.0842389659712649442845"), default=default)
185
181
  b'\xb80.0842389659712649442845'
186
182
  >>> ormsgpack.packb({1, 2}, default=default)
187
- ormsgpack.MsgpackEncodeError: Type is not msgpack serializable: set
183
+ TypeError: Type is not msgpack serializable: set
188
184
  ```
189
185
 
190
186
  The `default` callable may return an object that itself
@@ -196,13 +192,14 @@ Python otherwise implicitly returns `None`, which appears to the caller
196
192
  like a legitimate value and is serialized:
197
193
 
198
194
  ```python
199
- >>> import ormsgpack, json, rapidjson
200
- >>>
201
- def default(obj):
202
- if isinstance(obj, decimal.Decimal):
203
- return str(obj)
204
-
205
- >>> ormsgpack.unpackb(ormsgpack.packb({"set":{1, 2}}, default=default))
195
+ >>> import ormsgpack, decimal
196
+ >>> def default(obj):
197
+ ... if isinstance(obj, decimal.Decimal):
198
+ ... return str(obj)
199
+ ...
200
+ >>> ormsgpack.packb({"set":{1, 2}}, default=default)
201
+ b'\x81\xa3set\xc0'
202
+ >>> ormsgpack.unpackb(_)
206
203
  {'set': None}
207
204
  ```
208
205
 
@@ -213,12 +210,11 @@ value, respectively.
213
210
 
214
211
  ```python
215
212
  >>> import ormsgpack, decimal
216
- >>>
217
- def default(obj):
218
- if isinstance(obj, decimal.Decimal):
219
- return ormsgpack.Ext(0, str(obj).encode())
220
- raise TypeError
221
-
213
+ >>> def default(obj):
214
+ ... if isinstance(obj, decimal.Decimal):
215
+ ... return ormsgpack.Ext(0, str(obj).encode())
216
+ ... raise TypeError
217
+ ...
222
218
  >>> ormsgpack.packb(decimal.Decimal("0.0842389659712649442845"), default=default)
223
219
  b'\xc7\x18\x000.0842389659712649442845'
224
220
  ```
@@ -231,20 +227,25 @@ constant in `ormsgpack`. To specify multiple options, mask them together, e.g.,
231
227
 
232
228
  ##### OPT_NAIVE_UTC
233
229
 
234
- Serialize `datetime.datetime` objects without a `tzinfo` as UTC. This
235
- has no effect on `datetime.datetime` objects that have `tzinfo` set.
230
+ Serialize `datetime.datetime` objects without a `tzinfo` and `numpy.datetime64`
231
+ objects as UTC. This has no effect on `datetime.datetime` objects that have
232
+ `tzinfo` set.
236
233
 
237
234
  ```python
238
235
  >>> import ormsgpack, datetime
239
- >>> ormsgpack.unpackb(ormsgpack.packb(
240
- datetime.datetime(1970, 1, 1, 0, 0, 0),
241
- ))
242
- "1970-01-01T00:00:00"
243
- >>> ormsgpack.unpackb(ormsgpack.packb(
244
- datetime.datetime(1970, 1, 1, 0, 0, 0),
245
- option=ormsgpack.OPT_NAIVE_UTC,
246
- ))
247
- "1970-01-01T00:00:00+00:00"
236
+ >>> ormsgpack.packb(
237
+ ... datetime.datetime(1970, 1, 1, 0, 0, 0),
238
+ ... )
239
+ b'\xb31970-01-01T00:00:00'
240
+ >>> ormsgpack.unpackb(_)
241
+ '1970-01-01T00:00:00'
242
+ >>> ormsgpack.packb(
243
+ ... datetime.datetime(1970, 1, 1, 0, 0, 0),
244
+ ... option=ormsgpack.OPT_NAIVE_UTC,
245
+ ... )
246
+ b'\xb91970-01-01T00:00:00+00:00'
247
+ >>> ormsgpack.unpackb(_)
248
+ '1970-01-01T00:00:00+00:00'
248
249
  ```
249
250
 
250
251
  ##### OPT_NON_STR_KEYS
@@ -256,13 +257,19 @@ to be one of `str`, `int`, `float`, `bool`, `None`, `datetime.datetime`,
256
257
  ```python
257
258
  >>> import ormsgpack, datetime, uuid
258
259
  >>> ormsgpack.packb(
259
- {uuid.UUID("7202d115-7ff3-4c81-a7c1-2a1f067b1ece"): [1, 2, 3]},
260
- option=ormsgpack.OPT_NON_STR_KEYS,
261
- )
260
+ ... {uuid.UUID("7202d115-7ff3-4c81-a7c1-2a1f067b1ece"): [1, 2, 3]},
261
+ ... option=ormsgpack.OPT_NON_STR_KEYS,
262
+ ... )
263
+ b'\x81\xd9$7202d115-7ff3-4c81-a7c1-2a1f067b1ece\x93\x01\x02\x03'
264
+ >>> ormsgpack.unpackb(_)
265
+ {'7202d115-7ff3-4c81-a7c1-2a1f067b1ece': [1, 2, 3]}
262
266
  >>> ormsgpack.packb(
263
- {datetime.datetime(1970, 1, 1, 0, 0, 0): [1, 2, 3]},
264
- option=ormsgpack.OPT_NON_STR_KEYS | ormsgpack.OPT_NAIVE_UTC,
265
- )
267
+ ... {datetime.datetime(1970, 1, 1, 0, 0, 0): [1, 2, 3]},
268
+ ... option=ormsgpack.OPT_NON_STR_KEYS | ormsgpack.OPT_NAIVE_UTC,
269
+ ... )
270
+ b'\x81\xb91970-01-01T00:00:00+00:00\x93\x01\x02\x03'
271
+ >>> ormsgpack.unpackb(_)
272
+ {'1970-01-01T00:00:00+00:00': [1, 2, 3]}
266
273
  ```
267
274
 
268
275
  These types are generally serialized how they would be as
@@ -279,18 +286,24 @@ This option is not compatible with `ormsgpack.OPT_SORT_KEYS`.
279
286
 
280
287
  ##### OPT_OMIT_MICROSECONDS
281
288
 
282
- Do not serialize the `microsecond` field on `datetime.datetime` and
283
- `datetime.time` instances.
289
+ Do not serialize the microsecond component of `datetime.datetime`,
290
+ `datetime.time` and `numpy.datetime64` instances.
284
291
 
285
292
  ```python
286
293
  >>> import ormsgpack, datetime
287
294
  >>> ormsgpack.packb(
288
- datetime.datetime(1970, 1, 1, 0, 0, 0, 1),
289
- )
295
+ ... datetime.datetime(1970, 1, 1, 0, 0, 0, 1),
296
+ ... )
297
+ b'\xba1970-01-01T00:00:00.000001'
298
+ >>> ormsgpack.unpackb(_)
299
+ '1970-01-01T00:00:00.000001'
290
300
  >>> ormsgpack.packb(
291
- datetime.datetime(1970, 1, 1, 0, 0, 0, 1),
292
- option=ormsgpack.OPT_OMIT_MICROSECONDS,
293
- )
301
+ ... datetime.datetime(1970, 1, 1, 0, 0, 0, 1),
302
+ ... option=ormsgpack.OPT_OMIT_MICROSECONDS,
303
+ ... )
304
+ b'\xb31970-01-01T00:00:00'
305
+ >>> ormsgpack.unpackb(_)
306
+ '1970-01-01T00:00:00'
294
307
  ```
295
308
 
296
309
  ##### OPT_PASSTHROUGH_BIG_INT
@@ -300,16 +313,16 @@ Enables passthrough of big (Python) ints. By setting this option, one can set a
300
313
  ```python
301
314
  >>> import ormsgpack
302
315
  >>> ormsgpack.packb(
303
- 2**65,
304
- )
316
+ ... 2**65,
317
+ ... )
305
318
  TypeError: Integer exceeds 64-bit range
306
- >>> ormsgpack.unpackb(
307
- ormsgpack.packb(
308
- 2**65,
309
- option=ormsgpack.OPT_PASSTHROUGH_BIG_INT,
310
- default=lambda _: {"type": "bigint", "value": str(_) }
311
- )
312
- )
319
+ >>> ormsgpack.packb(
320
+ ... 2**65,
321
+ ... option=ormsgpack.OPT_PASSTHROUGH_BIG_INT,
322
+ ... default=lambda _: {"type": "bigint", "value": str(_) }
323
+ ... )
324
+ b'\x82\xa4type\xa6bigint\xa5value\xb436893488147419103232'
325
+ >>> ormsgpack.unpackb(_)
313
326
  {'type': 'bigint', 'value': '36893488147419103232'}
314
327
  ```
315
328
 
@@ -321,27 +334,26 @@ customizing their output but is much slower.
321
334
 
322
335
  ```python
323
336
  >>> import ormsgpack, dataclasses
324
- >>>
325
- @dataclasses.dataclass
326
- class User:
327
- id: str
328
- name: str
329
- password: str
330
-
331
- def default(obj):
332
- if isinstance(obj, User):
333
- return {"id": obj.id, "name": obj.name}
334
- raise TypeError
335
-
337
+ >>> @dataclasses.dataclass
338
+ ... class User:
339
+ ... id: str
340
+ ... name: str
341
+ ... password: str
342
+ ...
343
+ >>> def default(obj):
344
+ ... if isinstance(obj, User):
345
+ ... return {"id": obj.id, "name": obj.name}
346
+ ... raise TypeError
347
+ ...
336
348
  >>> ormsgpack.packb(User("3b1", "asd", "zxc"))
337
349
  b'\x83\xa2id\xa33b1\xa4name\xa3asd\xa8password\xa3zxc'
338
350
  >>> ormsgpack.packb(User("3b1", "asd", "zxc"), option=ormsgpack.OPT_PASSTHROUGH_DATACLASS)
339
351
  TypeError: Type is not msgpack serializable: User
340
352
  >>> ormsgpack.packb(
341
- User("3b1", "asd", "zxc"),
342
- option=ormsgpack.OPT_PASSTHROUGH_DATACLASS,
343
- default=default,
344
- )
353
+ ... User("3b1", "asd", "zxc"),
354
+ ... option=ormsgpack.OPT_PASSTHROUGH_DATACLASS,
355
+ ... default=default,
356
+ ... )
345
357
  b'\x82\xa2id\xa33b1\xa4name\xa3asd'
346
358
  ```
347
359
 
@@ -353,21 +365,20 @@ HTTP dates:
353
365
 
354
366
  ```python
355
367
  >>> import ormsgpack, datetime
356
- >>>
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
-
368
+ >>> def default(obj):
369
+ ... if isinstance(obj, datetime.datetime):
370
+ ... return obj.strftime("%a, %d %b %Y %H:%M:%S GMT")
371
+ ... raise TypeError
372
+ ...
362
373
  >>> ormsgpack.packb({"created_at": datetime.datetime(1970, 1, 1)})
363
374
  b'\x81\xaacreated_at\xb31970-01-01T00:00:00'
364
375
  >>> ormsgpack.packb({"created_at": datetime.datetime(1970, 1, 1)}, option=ormsgpack.OPT_PASSTHROUGH_DATETIME)
365
376
  TypeError: Type is not msgpack serializable: datetime.datetime
366
377
  >>> ormsgpack.packb(
367
- {"created_at": datetime.datetime(1970, 1, 1)},
368
- option=ormsgpack.OPT_PASSTHROUGH_DATETIME,
369
- default=default,
370
- )
378
+ ... {"created_at": datetime.datetime(1970, 1, 1)},
379
+ ... option=ormsgpack.OPT_PASSTHROUGH_DATETIME,
380
+ ... default=default,
381
+ ... )
371
382
  b'\x81\xaacreated_at\xbdThu, 01 Jan 1970 00:00:00 GMT'
372
383
  ```
373
384
 
@@ -379,15 +390,14 @@ Passthrough subclasses of builtin types to `default`.
379
390
 
380
391
  ```python
381
392
  >>> import ormsgpack
382
- >>>
383
- class Secret(str):
384
- pass
385
-
386
- def default(obj):
387
- if isinstance(obj, Secret):
388
- return "******"
389
- raise TypeError
390
-
393
+ >>> class Secret(str):
394
+ ... pass
395
+ ...
396
+ >>> def default(obj):
397
+ ... if isinstance(obj, Secret):
398
+ ... return "******"
399
+ ... raise TypeError
400
+ ...
391
401
  >>> ormsgpack.packb(Secret("zxc"))
392
402
  b'\xa3zxc'
393
403
  >>> ormsgpack.packb(Secret("zxc"), option=ormsgpack.OPT_PASSTHROUGH_SUBCLASS)
@@ -405,19 +415,19 @@ Passthrough tuples to `default`.
405
415
 
406
416
  ```python
407
417
  >>> import ormsgpack
408
- >>> ormsgpack.unpackb(
409
- ormsgpack.packb(
410
- (9193, "test", 42),
411
- )
412
- )
418
+ >>> ormsgpack.packb(
419
+ ... (9193, "test", 42),
420
+ ... )
421
+ b'\x93\xcd#\xe9\xa4test*'
422
+ >>> ormsgpack.unpackb(_)
413
423
  [9193, 'test', 42]
414
- >>> ormsgpack.unpackb(
415
- ormsgpack.packb(
416
- (9193, "test", 42),
417
- option=ormsgpack.OPT_PASSTHROUGH_TUPLE,
418
- default=lambda _: {"type": "tuple", "value": list(_)}
419
- )
420
- )
424
+ >>> ormsgpack.packb(
425
+ ... (9193, "test", 42),
426
+ ... option=ormsgpack.OPT_PASSTHROUGH_TUPLE,
427
+ ... default=lambda _: {"type": "tuple", "value": list(_)}
428
+ ... )
429
+ b'\x82\xa4type\xa5tuple\xa5value\x93\xcd#\xe9\xa4test*'
430
+ >>> ormsgpack.unpackb(_)
421
431
  {'type': 'tuple', 'value': [9193, 'test', 42]}
422
432
  ```
423
433
 
@@ -457,20 +467,20 @@ b'\x83\xa1A\x03\xa1a\x01\xa2\xc3\xa4\x02'
457
467
 
458
468
  ##### OPT_UTC_Z
459
469
 
460
- Serialize a UTC timezone on `datetime.datetime` instances as `Z` instead
461
- of `+00:00`.
470
+ Serialize a UTC timezone on `datetime.datetime` and `numpy.datetime64` instances
471
+ as `Z` instead of `+00:00`.
462
472
 
463
473
  ```python
464
474
  >>> import ormsgpack, datetime
465
475
  >>> ormsgpack.packb(
466
- datetime.datetime(1970, 1, 1, 0, 0, 0, tzinfo=datetime.timezone.utc),
467
- )
468
- b'"1970-01-01T00:00:00+00:00"'
476
+ ... datetime.datetime(1970, 1, 1, 0, 0, 0, tzinfo=datetime.timezone.utc),
477
+ ... )
478
+ b'\xb91970-01-01T00:00:00+00:00'
469
479
  >>> ormsgpack.packb(
470
- datetime.datetime(1970, 1, 1, 0, 0, 0, tzinfo=datetime.timezone.utc),
471
- option=ormsgpack.OPT_UTC_Z
472
- )
473
- b'"1970-01-01T00:00:00Z"'
480
+ ... datetime.datetime(1970, 1, 1, 0, 0, 0, tzinfo=datetime.timezone.utc),
481
+ ... option=ormsgpack.OPT_UTC_Z
482
+ ... )
483
+ b'\xb41970-01-01T00:00:00Z'
474
484
  ```
475
485
 
476
486
  ### Deserialize
@@ -507,21 +517,21 @@ extension type and value as arguments.
507
517
 
508
518
  ```python
509
519
  >>> import ormsgpack, decimal
510
- >>>
511
- def ext_hook(tag, data):
512
- if tag == 0:
513
- return decimal.Decimal(data.decode())
514
- raise TypeError
515
-
520
+ >>> def ext_hook(tag, data):
521
+ ... if tag == 0:
522
+ ... return decimal.Decimal(data.decode())
523
+ ... raise TypeError
524
+ ...
516
525
  >>> ormsgpack.packb(
517
- ormsgpack.Ext(0, str(decimal.Decimal("0.0842389659712649442845")).encode())
518
- )
526
+ ... ormsgpack.Ext(0, str(decimal.Decimal("0.0842389659712649442845")).encode())
527
+ ... )
528
+ b'\xc7\x18\x000.0842389659712649442845'
519
529
  >>> ormsgpack.unpackb(_, ext_hook=ext_hook)
520
- Decimal('0.0842389659712649442845')
530
+ Decimal('0.0842389659712649442845'
521
531
  ```
522
532
 
523
533
  #### option
524
- `unpackb()` supports the `OPT_NON_STR_KEYS` option, that is similar to original msgpack's `strict_map_keys=False`.
534
+ `unpackb()` supports the `OPT_NON_STR_KEYS` option, that is similar to original msgpack's `strict_map_key=False`.
525
535
  Be aware that this option is considered unsafe and disabled by default in msgpack due to possibility of HashDoS.
526
536
 
527
537
  ## Types
@@ -542,27 +552,20 @@ the order given on class definition:
542
552
 
543
553
  ```python
544
554
  >>> import dataclasses, ormsgpack, typing
545
-
546
- @dataclasses.dataclass
547
- class Member:
548
- id: int
549
- active: bool = dataclasses.field(default=False)
550
-
551
- @dataclasses.dataclass
552
- class Object:
553
- id: int
554
- name: str
555
- members: typing.List[Member]
556
-
555
+ >>> @dataclasses.dataclass
556
+ ... class Member:
557
+ ... id: int
558
+ ... active: bool = dataclasses.field(default=False)
559
+ ...
560
+ >>> @dataclasses.dataclass
561
+ ... class Object:
562
+ ... id: int
563
+ ... name: str
564
+ ... members: typing.List[Member]
565
+ ...
557
566
  >>> ormsgpack.packb(Object(1, "a", [Member(1, True), Member(2)]))
558
567
  b'\x83\xa2id\x01\xa4name\xa1a\xa7members\x92\x82\xa2id\x01\xa6active\xc3\x82\xa2id\x02\xa6active\xc2'
559
568
  ```
560
- Users may wish to control how dataclass instances are serialized, e.g.,
561
- to not serialize an attribute or to change the name of an
562
- attribute when serialized. ormsgpack may implement support using the
563
- metadata mapping on `field` attributes,
564
- e.g., `field(metadata={"json_serialize": False})`, if use cases are clear.
565
-
566
569
  #### Performance
567
570
  ![alt text](doc/dataclass.svg "dataclass")
568
571
 
@@ -585,20 +588,23 @@ compatible with `isoformat()` in the standard library.
585
588
  ```python
586
589
  >>> import ormsgpack, datetime, zoneinfo
587
590
  >>> ormsgpack.packb(
588
- datetime.datetime(2018, 12, 1, 2, 3, 4, 9, tzinfo=zoneinfo.ZoneInfo('Australia/Adelaide'))
589
- )
591
+ ... datetime.datetime(2018, 12, 1, 2, 3, 4, 9, tzinfo=zoneinfo.ZoneInfo('Australia/Adelaide'))
592
+ ... )
593
+ b'\xd9 2018-12-01T02:03:04.000009+10:30'
590
594
  >>> ormsgpack.unpackb(_)
591
- "2018-12-01T02:03:04.000009+10:30"
595
+ '2018-12-01T02:03:04.000009+10:30'
592
596
  >>> ormsgpack.packb(
593
- datetime.datetime.fromtimestamp(4123518902).replace(tzinfo=datetime.timezone.utc)
594
- )
597
+ ... datetime.datetime.fromtimestamp(4123518902).replace(tzinfo=datetime.timezone.utc)
598
+ ... )
599
+ b'\xb92100-09-02T00:55:02+00:00'
595
600
  >>> ormsgpack.unpackb(_)
596
- "2100-09-01T21:55:02+00:00"
601
+ '2100-09-02T00:55:02+00:00'
597
602
  >>> ormsgpack.packb(
598
- datetime.datetime.fromtimestamp(4123518902)
599
- )
603
+ ... datetime.datetime.fromtimestamp(4123518902)
604
+ ... )
605
+ b'\xb32100-09-02T00:55:02'
600
606
  >>> ormsgpack.unpackb(_)
601
- "2100-09-01T21:55:02"
607
+ '2100-09-02T00:55:02'
602
608
  ```
603
609
 
604
610
  `datetime.datetime` supports instances with a `tzinfo` that is `None`,
@@ -611,8 +617,9 @@ module, or a timezone instance from the third-party `pendulum`, `pytz`, or
611
617
  ```python
612
618
  >>> import ormsgpack, datetime
613
619
  >>> ormsgpack.packb(datetime.time(12, 0, 15, 290))
620
+ b'\xaf12:00:15.000290'
614
621
  >>> ormsgpack.unpackb(_)
615
- "12:00:15.000290"
622
+ '12:00:15.000290'
616
623
  ```
617
624
 
618
625
  `datetime.date` objects will always serialize.
@@ -620,8 +627,9 @@ module, or a timezone instance from the third-party `pendulum`, `pytz`, or
620
627
  ```python
621
628
  >>> import ormsgpack, datetime
622
629
  >>> ormsgpack.packb(datetime.date(1900, 1, 2))
630
+ b'\xaa1900-01-02'
623
631
  >>> ormsgpack.unpackb(_)
624
- "1900-01-02"
632
+ '1900-01-02'
625
633
  ```
626
634
 
627
635
  Errors with `tzinfo` result in `MsgpackEncodeError` being raised.
@@ -640,15 +648,17 @@ ormsgpack serializes enums natively. Options apply to their values.
640
648
 
641
649
  ```python
642
650
  >>> import enum, datetime, ormsgpack
643
- >>>
644
- class DatetimeEnum(enum.Enum):
645
- EPOCH = datetime.datetime(1970, 1, 1, 0, 0, 0)
651
+ >>> class DatetimeEnum(enum.Enum):
652
+ ... EPOCH = datetime.datetime(1970, 1, 1, 0, 0, 0)
653
+ ...
646
654
  >>> ormsgpack.packb(DatetimeEnum.EPOCH)
655
+ b'\xb31970-01-01T00:00:00'
647
656
  >>> ormsgpack.unpackb(_)
648
- "1970-01-01T00:00:00"
657
+ '1970-01-01T00:00:00'
649
658
  >>> ormsgpack.packb(DatetimeEnum.EPOCH, option=ormsgpack.OPT_NAIVE_UTC)
659
+ b'\xb91970-01-01T00:00:00+00:00'
650
660
  >>> ormsgpack.unpackb(_)
651
- "1970-01-01T00:00:00+00:00"
661
+ '1970-01-01T00:00:00+00:00'
652
662
  ```
653
663
 
654
664
  Enums with members that are not supported types can be serialized using
@@ -656,20 +666,20 @@ Enums with members that are not supported types can be serialized using
656
666
 
657
667
  ```python
658
668
  >>> import enum, ormsgpack
659
- >>>
660
- class Custom:
661
- def __init__(self, val):
662
- self.val = val
663
-
664
- def default(obj):
665
- if isinstance(obj, Custom):
666
- return obj.val
667
- raise TypeError
668
-
669
- class CustomEnum(enum.Enum):
670
- ONE = Custom(1)
671
-
669
+ >>> class Custom:
670
+ ... def __init__(self, val):
671
+ ... self.val = val
672
+ ...
673
+ >>> def default(obj):
674
+ ... if isinstance(obj, Custom):
675
+ ... return obj.val
676
+ ... raise TypeError
677
+ ...
678
+ >>> class CustomEnum(enum.Enum):
679
+ ... ONE = Custom(1)
680
+ ...
672
681
  >>> ormsgpack.packb(CustomEnum.ONE, default=default)
682
+ b'\x01'
673
683
  >>> ormsgpack.unpackb(_)
674
684
  1
675
685
  ```
@@ -688,12 +698,14 @@ an unsigned 64-bit integer's maximum (18446744073709551615).
688
698
  ### numpy
689
699
 
690
700
  ormsgpack natively serializes `numpy.ndarray` and individual
691
- `numpy.float64`, `numpy.float32`,
701
+ `numpy.float64`, `numpy.float32`, `numpy.float16`,
692
702
  `numpy.int64`, `numpy.int32`, `numpy.int16`, `numpy.int8`,
693
703
  `numpy.uint64`, `numpy.uint32`, `numpy.uint16`, `numpy.uint8`,
694
- `numpy.uintp`, `numpy.intp`, and `numpy.bool`
704
+ `numpy.uintp`, `numpy.intp`, `numpy.datetime64`, and `numpy.bool`
695
705
  instances.
696
706
 
707
+ `numpy.datetime64` instances are serialized as RFC 3339 strings.
708
+
697
709
  ormsgpack is faster than all compared libraries at serializing
698
710
  numpy instances. Serializing numpy data requires specifying
699
711
  `option=ormsgpack.OPT_SERIALIZE_NUMPY`.
@@ -701,11 +713,12 @@ numpy instances. Serializing numpy data requires specifying
701
713
  ```python
702
714
  >>> import ormsgpack, numpy
703
715
  >>> ormsgpack.packb(
704
- numpy.array([[1, 2, 3], [4, 5, 6]]),
705
- option=ormsgpack.OPT_SERIALIZE_NUMPY,
706
- )
716
+ ... numpy.array([[1, 2, 3], [4, 5, 6]]),
717
+ ... option=ormsgpack.OPT_SERIALIZE_NUMPY,
718
+ ... )
719
+ b'\x92\x93\x01\x02\x03\x93\x04\x05\x06'
707
720
  >>> ormsgpack.unpackb(_)
708
- [[1,2,3],[4,5,6]]
721
+ [[1, 2, 3], [4, 5, 6]]
709
722
  ```
710
723
 
711
724
  The array must be a contiguous C array (`C_CONTIGUOUS`) and one of the
@@ -769,14 +782,16 @@ ormsgpack serializes `uuid.UUID` instances to
769
782
  [RFC 4122](https://tools.ietf.org/html/rfc4122) format, e.g.,
770
783
  "f81d4fae-7dec-11d0-a765-00a0c91e6bf6".
771
784
 
772
- ``` python
785
+ ```python
773
786
  >>> import ormsgpack, uuid
774
787
  >>> ormsgpack.packb(uuid.UUID('f81d4fae-7dec-11d0-a765-00a0c91e6bf6'))
788
+ b'\xd9$f81d4fae-7dec-11d0-a765-00a0c91e6bf6'
775
789
  >>> ormsgpack.unpackb(_)
776
- "f81d4fae-7dec-11d0-a765-00a0c91e6bf6"
790
+ 'f81d4fae-7dec-11d0-a765-00a0c91e6bf6'
777
791
  >>> ormsgpack.packb(uuid.uuid5(uuid.NAMESPACE_DNS, "python.org"))
792
+ b'\xd9$886313e1-3b8a-5372-9b90-0c9aee199e5d'
778
793
  >>> ormsgpack.unpackb(_)
779
- "886313e1-3b8a-5372-9b90-0c9aee199e5d"
794
+ '886313e1-3b8a-5372-9b90-0c9aee199e5d
780
795
  ```
781
796
 
782
797
  ### Pydantic
@@ -887,10 +902,6 @@ No. This requires a schema specifying what types are expected and how to
887
902
  handle errors etc. This is addressed by data validation libraries a
888
903
  level above this.
889
904
 
890
- ### Will it support PyPy?
891
-
892
- If someone implements it well.
893
-
894
905
  ## Packaging
895
906
 
896
907
  To package ormsgpack requires [Rust](https://www.rust-lang.org/) 1.65
@@ -903,7 +914,7 @@ is:
903
914
  maturin build --release --strip
904
915
  ```
905
916
 
906
- ormsgpack is tested for amd64 on Linux, macOS, and Windows.
917
+ ormsgpack is tested on Linux/amd64, Linux/aarch64, Linux/armv7, macOS/amd64 and Windows/amd64.
907
918
 
908
919
  There are no runtime dependencies other than libc.
909
920
 
@@ -0,0 +1,9 @@
1
+ ormsgpack-1.5.0.dist-info/METADATA,sha256=KzJsbOVJn139IMkgpmb4bJyNZHBQrgrQNxo_E5QLQww,44803
2
+ ormsgpack-1.5.0.dist-info/WHEEL,sha256=7Ui73pGgidyUA-5snShG0g3e0MxNIiYlCeND1YtcadQ,94
3
+ ormsgpack-1.5.0.dist-info/license_files/LICENSE-APACHE,sha256=fP1zjFPWHHnwfjSPYiv3cHyQhCNwVNN_vgd4inX1iBw,11048
4
+ ormsgpack-1.5.0.dist-info/license_files/LICENSE-MIT,sha256=NlFq79yExdWh50hUJZE6ItvaaesZMMXoTWrklytRlLk,1046
5
+ ormsgpack/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
+ ormsgpack/__init__.py,sha256=cO7CRlLMoqVgapEc5lz2nE0SNNuvi659IAbl0fYU4_Q,969
7
+ ormsgpack/__init__.pyi,sha256=vVfpvAXniV3FAfa546Ni7ZjwYfb4l0OevDCkK2SH9CQ,784
8
+ ormsgpack/ormsgpack.cp39-win_amd64.pyd,sha256=hzBIOSAJYPLawM3atM8FwqUH8o97LqlFdfbBYs3-17o,291840
9
+ ormsgpack-1.5.0.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: maturin (1.3.1)
2
+ Generator: maturin (1.5.1)
3
3
  Root-Is-Purelib: false
4
4
  Tag: cp39-none-win_amd64
@@ -1,9 +0,0 @@
1
- ormsgpack-1.4.1.dist-info/METADATA,sha256=0nsqWb3DQK3nLDmG5xqY5Ty3hviYoVhW-sEKRQDVy_8,43847
2
- ormsgpack-1.4.1.dist-info/WHEEL,sha256=GPoikEx9UJPzzwvyvn6gutcC22zDvOrF9d2iCdomep4,94
3
- ormsgpack-1.4.1.dist-info/license_files/LICENSE-APACHE,sha256=fP1zjFPWHHnwfjSPYiv3cHyQhCNwVNN_vgd4inX1iBw,11048
4
- ormsgpack-1.4.1.dist-info/license_files/LICENSE-MIT,sha256=NlFq79yExdWh50hUJZE6ItvaaesZMMXoTWrklytRlLk,1046
5
- ormsgpack/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
- ormsgpack/__init__.py,sha256=jGcrk6dQSfTAgcqkXznT4VlrV-z9KZ9t6bHuDepqfJA,583
7
- ormsgpack/__init__.pyi,sha256=vVfpvAXniV3FAfa546Ni7ZjwYfb4l0OevDCkK2SH9CQ,784
8
- ormsgpack/ormsgpack.cp39-win_amd64.pyd,sha256=7hGnir-tvczxpaUfDgRYYrYYJCf2oPKAckpkNGdwF5k,280576
9
- ormsgpack-1.4.1.dist-info/RECORD,,