ormsgpack 1.3.0__cp38-none-win_amd64.whl → 1.4.1__cp38-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
@@ -7,6 +7,7 @@ __all__ = (
7
7
  "__version__",
8
8
  "packb",
9
9
  "unpackb",
10
+ "Ext",
10
11
  "MsgpackDecodeError",
11
12
  "MsgpackEncodeError",
12
13
  "OPT_NAIVE_UTC",
ormsgpack/__init__.pyi CHANGED
@@ -8,7 +8,9 @@ def packb(
8
8
  option: Optional[int] = None,
9
9
  ) -> bytes: ...
10
10
  def unpackb(
11
- __obj: Union[str, bytes, bytearray, memoryview], option: Optional[int] = ...
11
+ __obj: Union[str, bytes, bytearray, memoryview],
12
+ ext_hook: Optional[Callable[[int, bytes], Any]] = ...,
13
+ option: Optional[int] = ...,
12
14
  ) -> Any: ...
13
15
 
14
16
  class MsgpackDecodeError(ValueError): ...
Binary file
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ormsgpack
3
- Version: 1.3.0
3
+ Version: 1.4.1
4
4
  Classifier: Development Status :: 5 - Production/Stable
5
5
  Classifier: Intended Audience :: Developers
6
6
  Classifier: License :: OSI Approved :: Apache Software License
@@ -37,11 +37,11 @@ Project-URL: Source Code, https://github.com/aviramha/ormsgpack
37
37
  ormsgpack is a fast msgpack library for Python. It is a fork/reboot of [orjson](https://github.com/ijl/orjson)
38
38
  It serializes faster than [msgpack-python](https://github.com/msgpack/msgpack-python) and deserializes a bit slower (right now).
39
39
  It supports serialization of:
40
- [dataclass](https://github.com/aviramha/ormsgpack#dataclass),
41
- [datetime](https://github.com/aviramha/ormsgpack#datetime),
42
- [numpy](https://github.com/aviramha/ormsgpack#numpy),
43
- [pydantic](https://github.com/aviramha/ormsgpack#OPT_SERIALIZE_PYDANTIC) and
44
- [UUID](https://github.com/aviramha/ormsgpack#uuid) instances natively.
40
+ [dataclass](#dataclass),
41
+ [datetime](#datetime),
42
+ [numpy](#numpy),
43
+ [pydantic](#pydantic) and
44
+ [UUID](#uuid) instances natively.
45
45
 
46
46
  Its features and drawbacks compared to other Python msgpack libraries:
47
47
 
@@ -49,7 +49,7 @@ Its features and drawbacks compared to other Python msgpack libraries:
49
49
  * serializes `datetime`, `date`, and `time` instances to RFC 3339 format,
50
50
  e.g., "1970-01-01T00:00:00+00:00"
51
51
  * serializes `numpy.ndarray` instances natively and faster.
52
- * serializes `pydantic.BaseModel` instances natively (disregards the configuration ATM).
52
+ * serializes `pydantic.BaseModel` instances natively
53
53
  * serializes arbitrary types using a `default` hook
54
54
 
55
55
  ormsgpack supports CPython 3.8, 3.9, 3.10, 3.11 and 3.12. ormsgpack does not support PyPy. Releases follow semantic
@@ -63,26 +63,26 @@ submitted there. There is a
63
63
  [CHANGELOG](https://github.com/aviramha/ormsgpack/blob/master/CHANGELOG.md)
64
64
  available in the repository.
65
65
 
66
- 1. [Usage](https://github.com/aviramha/ormsgpack#usage)
67
- 1. [Install](https://github.com/aviramha/ormsgpack#install)
68
- 2. [Quickstart](https://github.com/aviramha/ormsgpack#quickstart)
69
- 4. [Serialize](https://github.com/aviramha/ormsgpack#serialize)
70
- 1. [default](https://github.com/aviramha/ormsgpack#default)
71
- 2. [option](https://github.com/aviramha/ormsgpack#option)
72
- 5. [Deserialize](https://github.com/aviramha/ormsgpack#deserialize)
73
- 2. [Types](https://github.com/aviramha/ormsgpack#types)
74
- 1. [dataclass](https://github.com/aviramha/ormsgpack#dataclass)
75
- 2. [datetime](https://github.com/aviramha/ormsgpack#datetime)
76
- 3. [enum](https://github.com/aviramha/ormsgpack#enum)
77
- 4. [float](https://github.com/aviramha/ormsgpack#float)
78
- 5. [int](https://github.com/aviramha/ormsgpack#int)
79
- 6. [numpy](https://github.com/aviramha/ormsgpack#numpy)
80
- 7. [uuid](https://github.com/aviramha/ormsgpack#uuid)
81
- 8. [pydantic](https://github.com/aviramha/ormsgpack#pydantic)
82
- 3. [Latency](https://github.com/aviramha/ormsgpack#latency)
83
- 4. [Questions](https://github.com/aviramha/ormsgpack#questions)
84
- 5. [Packaging](https://github.com/aviramha/ormsgpack#packaging)
85
- 6. [License](https://github.com/aviramha/ormsgpack#license)
66
+ 1. [Usage](#usage)
67
+ 1. [Install](#install)
68
+ 2. [Quickstart](#quickstart)
69
+ 4. [Serialize](#serialize)
70
+ 1. [default](#default)
71
+ 2. [option](#option)
72
+ 5. [Deserialize](#deserialize)
73
+ 2. [Types](#types)
74
+ 1. [dataclass](#dataclass)
75
+ 2. [datetime](#datetime)
76
+ 3. [enum](#enum)
77
+ 4. [float](#float)
78
+ 5. [int](#int)
79
+ 6. [numpy](#numpy)
80
+ 7. [uuid](#uuid)
81
+ 8. [pydantic](#pydantic)
82
+ 3. [Latency](#latency)
83
+ 4. [Questions](#questions)
84
+ 5. [Packaging](#packaging)
85
+ 6. [License](#license)
86
86
 
87
87
  ## Usage
88
88
 
@@ -98,7 +98,7 @@ pip install --upgrade ormsgpack
98
98
  Notice that Linux environments with a `pip` version shipped in 2018 or earlier
99
99
  must first upgrade `pip` to support `manylinux2014` wheels.
100
100
 
101
- To build a wheel, see [packaging](https://github.com/aviramha/ormsgpack#packaging).
101
+ To build a wheel, see [packaging](#packaging).
102
102
 
103
103
  ### Quickstart
104
104
 
@@ -146,8 +146,8 @@ The global interpreter lock (GIL) is held for the duration of the call.
146
146
 
147
147
  It raises `MsgpackEncodeError` on an unsupported type. This exception message
148
148
  describes the invalid object with the error message
149
- `Type is not JSON serializable: ...`. To fix this, specify
150
- [default](https://github.com/aviramha/ormsgpack#default).
149
+ `Type is not msgpack serializable: ...`. To fix this, specify
150
+ [default](#default).
151
151
 
152
152
  It raises `MsgpackEncodeError` on a `str` that contains invalid UTF-8.
153
153
 
@@ -162,8 +162,7 @@ It raises `MsgpackEncodeError` on circular references.
162
162
  It raises `MsgpackEncodeError` if a `tzinfo` on a datetime object is
163
163
  unsupported.
164
164
 
165
- `MsgpackEncodeError` is a subclass of `TypeError`. This is for compatibility
166
- with the standard library.
165
+ `MsgpackEncodeError` is a subclass of `TypeError`.
167
166
 
168
167
  #### default
169
168
 
@@ -181,7 +180,7 @@ def default(obj):
181
180
  raise TypeError
182
181
 
183
182
  >>> ormsgpack.packb(decimal.Decimal("0.0842389659712649442845"))
184
- MsgpackEncodeError: Type is not JSON serializable: decimal.Decimal
183
+ MsgpackEncodeError: Type is not msgpack serializable: decimal.Decimal
185
184
  >>> ormsgpack.packb(decimal.Decimal("0.0842389659712649442845"), default=default)
186
185
  b'\xb80.0842389659712649442845'
187
186
  >>> ormsgpack.packb({1, 2}, default=default)
@@ -207,6 +206,23 @@ def default(obj):
207
206
  {'set': None}
208
207
  ```
209
208
 
209
+ To serialize a type as a MessagePack extension type, return an
210
+ `ormsgpack.Ext` object. The instantiation arguments are an integer in
211
+ the range `[0, 127]` and a `bytes` object, defining the type and
212
+ value, respectively.
213
+
214
+ ```python
215
+ >>> 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
+
222
+ >>> ormsgpack.packb(decimal.Decimal("0.0842389659712649442845"), default=default)
223
+ b'\xc7\x18\x000.0842389659712649442845'
224
+ ```
225
+
210
226
  #### option
211
227
 
212
228
  To modify how data is serialized, specify `option`. Each `option` is an integer
@@ -235,9 +251,7 @@ has no effect on `datetime.datetime` objects that have `tzinfo` set.
235
251
 
236
252
  Serialize `dict` keys of type other than `str`. This allows `dict` keys
237
253
  to be one of `str`, `int`, `float`, `bool`, `None`, `datetime.datetime`,
238
- `datetime.date`, `datetime.time`, `enum.Enum`, and `uuid.UUID`. For comparison,
239
- the standard library serializes `str`, `int`, `float`, `bool` or `None` by
240
- default.
254
+ `datetime.date`, `datetime.time`, `enum.Enum`, and `uuid.UUID`.
241
255
 
242
256
  ```python
243
257
  >>> import ormsgpack, datetime, uuid
@@ -410,17 +424,15 @@ Passthrough tuples to `default`.
410
424
  ##### OPT_SERIALIZE_NUMPY
411
425
 
412
426
  Serialize `numpy.ndarray` instances. For more, see
413
- [numpy](https://github.com/aviramha/ormsgpack#numpy).
427
+ [numpy](#numpy).
414
428
 
415
429
  ##### OPT_SERIALIZE_PYDANTIC
416
- Serialize `pydantic.BaseModel` instances. Right now it ignores the config (str transformations), support might be added
417
- later.
430
+ Serialize `pydantic.BaseModel` instances.
418
431
 
419
432
  ##### OPT_SORT_KEYS
420
433
 
421
434
  Serialize `dict` keys in sorted order. The default is to serialize in an
422
- unspecified order. This is equivalent to `sort_keys=True` in the standard
423
- library.
435
+ unspecified order.
424
436
 
425
437
  This can be used to ensure the order is deterministic for hashing or tests.
426
438
  It has a substantial performance penalty and is not recommended in general.
@@ -441,8 +453,6 @@ The sorting is not collation/locale-aware:
441
453
  b'\x83\xa1A\x03\xa1a\x01\xa2\xc3\xa4\x02'
442
454
  ```
443
455
 
444
- This is the same sorting behavior as the standard library.
445
-
446
456
  `dataclass` also serialize as maps but this has no effect on them.
447
457
 
448
458
  ##### OPT_UTC_Z
@@ -465,7 +475,12 @@ b'"1970-01-01T00:00:00Z"'
465
475
 
466
476
  ### Deserialize
467
477
  ```python
468
- def unpackb(__obj: Union[bytes, bytearray, memoryview], / , option=None) -> Any: ...
478
+ def unpackb(
479
+ __obj: Union[bytes, bytearray, memoryview],
480
+ /,
481
+ ext_hook: Optional[Callable[[int, bytes], Any]] = ...,
482
+ option: Optional[int] = ...,
483
+ ) -> Any: ...
469
484
  ```
470
485
 
471
486
  `unpackb()` deserializes msgpack to Python objects. It deserializes to `dict`,
@@ -484,6 +499,27 @@ msgpack.
484
499
 
485
500
  `MsgpackDecodeError` is a subclass of `ValueError`.
486
501
 
502
+ #### ext_hook
503
+
504
+ To deserialize extension types, specify the optional `ext_hook`
505
+ argument. The value should be a callable and is invoked with the
506
+ extension type and value as arguments.
507
+
508
+ ```python
509
+ >>> import ormsgpack, decimal
510
+ >>>
511
+ def ext_hook(tag, data):
512
+ if tag == 0:
513
+ return decimal.Decimal(data.decode())
514
+ raise TypeError
515
+
516
+ >>> ormsgpack.packb(
517
+ ormsgpack.Ext(0, str(decimal.Decimal("0.0842389659712649442845")).encode())
518
+ )
519
+ >>> ormsgpack.unpackb(_, ext_hook=ext_hook)
520
+ Decimal('0.0842389659712649442845')
521
+ ```
522
+
487
523
  #### option
488
524
  `unpackb()` supports the `OPT_NON_STR_KEYS` option, that is similar to original msgpack's `strict_map_keys=False`.
489
525
  Be aware that this option is considered unsafe and disabled by default in msgpack due to possibility of HashDoS.
@@ -543,7 +579,7 @@ test_dataclass_msgpack 140.2774 (40.96) 143.6087 (18.42) 141.3847 (3
543
579
 
544
580
  ormsgpack serializes `datetime.datetime` objects to
545
581
  [RFC 3339](https://tools.ietf.org/html/rfc3339) format,
546
- e.g., "1970-01-01T00:00:00+00:00". This is a subset of ISO 8601 and
582
+ e.g., "1970-01-01T00:00:00+00:00". This is a subset of ISO 8601 and is
547
583
  compatible with `isoformat()` in the standard library.
548
584
 
549
585
  ```python
@@ -590,17 +626,13 @@ module, or a timezone instance from the third-party `pendulum`, `pytz`, or
590
626
 
591
627
  Errors with `tzinfo` result in `MsgpackEncodeError` being raised.
592
628
 
593
- It is faster to have ormsgpack serialize datetime objects than to do so
594
- before calling `packb()`. If using an unsupported type such as
595
- `pendulum.datetime`, use `default`.
596
-
597
629
  To disable serialization of `datetime` objects specify the option
598
630
  `ormsgpack.OPT_PASSTHROUGH_DATETIME`.
599
631
 
600
632
  To use "Z" suffix instead of "+00:00" to indicate UTC ("Zulu") time, use the option
601
633
  `ormsgpack.OPT_UTC_Z`.
602
634
 
603
- To assume datetimes without timezone are UTC, se the option `ormsgpack.OPT_NAIVE_UTC`.
635
+ To assume datetimes without timezone are UTC, use the option `ormsgpack.OPT_NAIVE_UTC`.
604
636
 
605
637
  ### enum
606
638
 
@@ -655,11 +687,13 @@ an unsigned 64-bit integer's maximum (18446744073709551615).
655
687
 
656
688
  ### numpy
657
689
 
658
- ormsgpack natively serializes `numpy.ndarray` and individual `numpy.float64`,
659
- `numpy.float32`, `numpy.int64`, `numpy.int32`, `numpy.int8`, `numpy.uint64`,
660
- `numpy.uint32`, and `numpy.uint8` instances. Arrays may have a
661
- `dtype` of `numpy.bool`, `numpy.float32`, `numpy.float64`, `numpy.int32`,
662
- `numpy.int64`, `numpy.uint32`, `numpy.uint64`, `numpy.uintp`, or `numpy.intp`.
690
+ ormsgpack natively serializes `numpy.ndarray` and individual
691
+ `numpy.float64`, `numpy.float32`,
692
+ `numpy.int64`, `numpy.int32`, `numpy.int16`, `numpy.int8`,
693
+ `numpy.uint64`, `numpy.uint32`, `numpy.uint16`, `numpy.uint8`,
694
+ `numpy.uintp`, `numpy.intp`, and `numpy.bool`
695
+ instances.
696
+
663
697
  ormsgpack is faster than all compared libraries at serializing
664
698
  numpy instances. Serializing numpy data requires specifying
665
699
  `option=ormsgpack.OPT_SERIALIZE_NUMPY`.
@@ -744,10 +778,12 @@ ormsgpack serializes `uuid.UUID` instances to
744
778
  >>> ormsgpack.unpackb(_)
745
779
  "886313e1-3b8a-5372-9b90-0c9aee199e5d"
746
780
  ```
781
+
747
782
  ### Pydantic
748
- ![alt text](doc/pydantic.svg "pydantic")
749
- ormsgpack serializes `pydantic.BaseModel` instances natively. Currently it ignores `pydantic.BaseModel.Config`.
783
+ ormsgpack serializes `pydantic.BaseModel` instances natively.
784
+
750
785
  #### Performance
786
+ ![alt text](doc/pydantic.svg "pydantic")
751
787
 
752
788
  ```
753
789
  -------------------------------------------------------------------------------- benchmark 'pydantic': 2 tests ---------------------------------------------------------------------------------
@@ -757,6 +793,7 @@ test_pydantic_ormsgpack 4.3918 (1.0) 12.6521 (1.0) 4.8550 (1.
757
793
  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
758
794
  ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
759
795
  ```
796
+
760
797
  ## Latency
761
798
  ### Graphs
762
799
  ![alt text](doc/twitter_packb.svg "twitter.json serialization")
@@ -856,36 +893,17 @@ If someone implements it well.
856
893
 
857
894
  ## Packaging
858
895
 
859
- To package ormsgpack requires [Rust](https://www.rust-lang.org/) on the
860
- nightly channel and the [maturin](https://github.com/PyO3/maturin)
861
- build tool. maturin can be installed from PyPI or packaged as
862
- well. This is the simplest and recommended way of installing
863
- from source, assuming `rustup` is available from a
864
- package manager:
896
+ To package ormsgpack requires [Rust](https://www.rust-lang.org/) 1.65
897
+ or newer and the [maturin](https://github.com/PyO3/maturin) build
898
+ tool. The default feature `unstable-simd` enables the usage of SIMD
899
+ operations and requires nightly Rust. The recommended build command
900
+ is:
865
901
 
866
902
  ```sh
867
- rustup default nightly
868
- pip wheel --no-binary=ormsgpack ormsgpack
903
+ maturin build --release --strip
869
904
  ```
870
905
 
871
- This is an example of building a wheel using the repository as source,
872
- `rustup` installed from upstream, and a pinned version of Rust:
873
-
874
- ```sh
875
- pip install maturin
876
- curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain nightly-2021-05-25 --profile minimal -y
877
- export RUSTFLAGS="-C target-cpu=k8"
878
- maturin build --release --strip --manylinux off
879
- ls -1 target/wheels
880
- ```
881
-
882
- Problems with the Rust nightly channel may require pinning a version.
883
- `nightly-2021-05-25` is known to be ok.
884
-
885
- ormsgpack is tested for amd64 and aarch64 on Linux, macOS, and Windows. It
886
- may not work on 32-bit targets. It has recommended `RUSTFLAGS`
887
- specified in `.cargo/config` so it is recommended to either not set
888
- `RUSTFLAGS` or include these options.
906
+ ormsgpack is tested for amd64 on Linux, macOS, and Windows.
889
907
 
890
908
  There are no runtime dependencies other than libc.
891
909
 
@@ -0,0 +1,9 @@
1
+ ormsgpack-1.4.1.dist-info/METADATA,sha256=0nsqWb3DQK3nLDmG5xqY5Ty3hviYoVhW-sEKRQDVy_8,43847
2
+ ormsgpack-1.4.1.dist-info/WHEEL,sha256=T1RLm43AXt41GKrFU5GP7AbI-r0Ir8iMFRaUAG9tOo0,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.cp38-win_amd64.pyd,sha256=tpEXzZA1mi_ABzhACWe6J6LeO3JV04YIZcW4tmuoLlw,280064
9
+ ormsgpack-1.4.1.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: maturin (1.3.0)
2
+ Generator: maturin (1.3.1)
3
3
  Root-Is-Purelib: false
4
4
  Tag: cp38-none-win_amd64
@@ -1,9 +0,0 @@
1
- ormsgpack-1.3.0.dist-info/METADATA,sha256=lmsRxG5lKniXeM6ua5ZxQp2OIJ807_senzboTRTquxw,45202
2
- ormsgpack-1.3.0.dist-info/WHEEL,sha256=VYinC71WLuLn3fOubSwjM4Pwno7UIsfdYgaVIbybp3o,94
3
- ormsgpack-1.3.0.dist-info/license_files/LICENSE-APACHE,sha256=fP1zjFPWHHnwfjSPYiv3cHyQhCNwVNN_vgd4inX1iBw,11048
4
- ormsgpack-1.3.0.dist-info/license_files/LICENSE-MIT,sha256=NlFq79yExdWh50hUJZE6ItvaaesZMMXoTWrklytRlLk,1046
5
- ormsgpack/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
- ormsgpack/__init__.py,sha256=G2SlQjBKVUXBe5DJQeAPWd6dU8lzQL8AHPPD-RyGbLc,571
7
- ormsgpack/__init__.pyi,sha256=X1zSvvHC-pSmtFnxyjIGh03uItz0Vg8mgJrUi7bXL9U,718
8
- ormsgpack/ormsgpack.cp38-win_amd64.pyd,sha256=ZRXXyuo-bvhXV5tkFZm7r3G5OXVXliZc9PjlU_gHc-o,295936
9
- ormsgpack-1.3.0.dist-info/RECORD,,