ormsgpack 1.3.0__cp312-none-win_amd64.whl → 1.4.0__cp312-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.0
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
 
@@ -147,7 +147,7 @@ The global interpreter lock (GIL) is held for the duration of the call.
147
147
  It raises `MsgpackEncodeError` on an unsupported type. This exception message
148
148
  describes the invalid object with the error message
149
149
  `Type is not JSON serializable: ...`. To fix this, specify
150
- [default](https://github.com/aviramha/ormsgpack#default).
150
+ [default](#default).
151
151
 
152
152
  It raises `MsgpackEncodeError` on a `str` that contains invalid UTF-8.
153
153
 
@@ -207,6 +207,23 @@ def default(obj):
207
207
  {'set': None}
208
208
  ```
209
209
 
210
+ To serialize a type as a MessagePack extension type, return an
211
+ `ormsgpack.Ext` object. The instantiation arguments are an integer in
212
+ the range `[0, 127]` and a `bytes` object, defining the type and
213
+ value, respectively.
214
+
215
+ ```python
216
+ >>> import ormsgpack, decimal
217
+ >>>
218
+ def default(obj):
219
+ if isinstance(obj, decimal.Decimal):
220
+ return ormsgpack.Ext(0, str(obj).encode())
221
+ raise TypeError
222
+
223
+ >>> ormsgpack.packb(decimal.Decimal("0.0842389659712649442845"), default=default)
224
+ b'\xc7\x18\x000.0842389659712649442845'
225
+ ```
226
+
210
227
  #### option
211
228
 
212
229
  To modify how data is serialized, specify `option`. Each `option` is an integer
@@ -410,11 +427,10 @@ Passthrough tuples to `default`.
410
427
  ##### OPT_SERIALIZE_NUMPY
411
428
 
412
429
  Serialize `numpy.ndarray` instances. For more, see
413
- [numpy](https://github.com/aviramha/ormsgpack#numpy).
430
+ [numpy](#numpy).
414
431
 
415
432
  ##### OPT_SERIALIZE_PYDANTIC
416
- Serialize `pydantic.BaseModel` instances. Right now it ignores the config (str transformations), support might be added
417
- later.
433
+ Serialize `pydantic.BaseModel` instances.
418
434
 
419
435
  ##### OPT_SORT_KEYS
420
436
 
@@ -465,7 +481,12 @@ b'"1970-01-01T00:00:00Z"'
465
481
 
466
482
  ### Deserialize
467
483
  ```python
468
- def unpackb(__obj: Union[bytes, bytearray, memoryview], / , option=None) -> Any: ...
484
+ def unpackb(
485
+ __obj: Union[bytes, bytearray, memoryview],
486
+ /,
487
+ ext_hook: Optional[Callable[[int, bytes], Any]] = ...,
488
+ option: Optional[int] = ...,
489
+ ) -> Any: ...
469
490
  ```
470
491
 
471
492
  `unpackb()` deserializes msgpack to Python objects. It deserializes to `dict`,
@@ -484,6 +505,27 @@ msgpack.
484
505
 
485
506
  `MsgpackDecodeError` is a subclass of `ValueError`.
486
507
 
508
+ #### ext_hook
509
+
510
+ To deserialize extension types, specify the optional `ext_hook`
511
+ argument. The value should be a callable and is invoked with the
512
+ extension type and value as arguments.
513
+
514
+ ```python
515
+ >>> import ormsgpack, decimal
516
+ >>>
517
+ def ext_hook(tag, data):
518
+ if tag == 0:
519
+ return decimal.Decimal(data.decode())
520
+ raise TypeError
521
+
522
+ >>> ormsgpack.packb(
523
+ ormsgpack.Ext(0, str(decimal.Decimal("0.0842389659712649442845")).encode())
524
+ )
525
+ >>> ormsgpack.unpackb(_, ext_hook=ext_hook)
526
+ Decimal('0.0842389659712649442845')
527
+ ```
528
+
487
529
  #### option
488
530
  `unpackb()` supports the `OPT_NON_STR_KEYS` option, that is similar to original msgpack's `strict_map_keys=False`.
489
531
  Be aware that this option is considered unsafe and disabled by default in msgpack due to possibility of HashDoS.
@@ -655,11 +697,13 @@ an unsigned 64-bit integer's maximum (18446744073709551615).
655
697
 
656
698
  ### numpy
657
699
 
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`.
700
+ ormsgpack natively serializes `numpy.ndarray` and individual
701
+ `numpy.float64`, `numpy.float32`,
702
+ `numpy.int64`, `numpy.int32`, `numpy.int16`, `numpy.int8`,
703
+ `numpy.uint64`, `numpy.uint32`, `numpy.uint16`, `numpy.uint8`,
704
+ `numpy.uintp`, `numpy.intp`, and `numpy.bool`
705
+ instances.
706
+
663
707
  ormsgpack is faster than all compared libraries at serializing
664
708
  numpy instances. Serializing numpy data requires specifying
665
709
  `option=ormsgpack.OPT_SERIALIZE_NUMPY`.
@@ -744,10 +788,12 @@ ormsgpack serializes `uuid.UUID` instances to
744
788
  >>> ormsgpack.unpackb(_)
745
789
  "886313e1-3b8a-5372-9b90-0c9aee199e5d"
746
790
  ```
791
+
747
792
  ### Pydantic
748
- ![alt text](doc/pydantic.svg "pydantic")
749
- ormsgpack serializes `pydantic.BaseModel` instances natively. Currently it ignores `pydantic.BaseModel.Config`.
793
+ ormsgpack serializes `pydantic.BaseModel` instances natively.
794
+
750
795
  #### Performance
796
+ ![alt text](doc/pydantic.svg "pydantic")
751
797
 
752
798
  ```
753
799
  -------------------------------------------------------------------------------- benchmark 'pydantic': 2 tests ---------------------------------------------------------------------------------
@@ -757,6 +803,7 @@ test_pydantic_ormsgpack 4.3918 (1.0) 12.6521 (1.0) 4.8550 (1.
757
803
  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
804
  ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
759
805
  ```
806
+
760
807
  ## Latency
761
808
  ### Graphs
762
809
  ![alt text](doc/twitter_packb.svg "twitter.json serialization")
@@ -856,36 +903,17 @@ If someone implements it well.
856
903
 
857
904
  ## Packaging
858
905
 
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:
865
-
866
- ```sh
867
- rustup default nightly
868
- pip wheel --no-binary=ormsgpack ormsgpack
869
- ```
870
-
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:
906
+ To package ormsgpack requires [Rust](https://www.rust-lang.org/) 1.65
907
+ or newer and the [maturin](https://github.com/PyO3/maturin) build
908
+ tool. The default feature `unstable-simd` enables the usage of SIMD
909
+ operations and requires nightly Rust. The recommended build command
910
+ is:
873
911
 
874
912
  ```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
913
+ maturin build --release --strip
880
914
  ```
881
915
 
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.
916
+ ormsgpack is tested for amd64 on Linux, macOS, and Windows.
889
917
 
890
918
  There are no runtime dependencies other than libc.
891
919
 
@@ -0,0 +1,9 @@
1
+ ormsgpack-1.4.0.dist-info/METADATA,sha256=6Khn9kj9zalRB68eOsdugIRBoPN8aa44zfh9oH4eUVo,44296
2
+ ormsgpack-1.4.0.dist-info/WHEEL,sha256=XsH2vPscYv__Aqy80BSCS0UnBLuefPBkBqWxyYzlkbg,95
3
+ ormsgpack-1.4.0.dist-info/license_files/LICENSE-APACHE,sha256=fP1zjFPWHHnwfjSPYiv3cHyQhCNwVNN_vgd4inX1iBw,11048
4
+ ormsgpack-1.4.0.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.cp312-win_amd64.pyd,sha256=tj0hr84kcvUL2922_0hgxncbE2GbzdogThsWbsrOoEg,280576
9
+ ormsgpack-1.4.0.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: cp312-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=Lw8U737y2DUrNOcX1MyEmRc5QSMlvwSnn88il8TtW9I,95
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.cp312-win_amd64.pyd,sha256=ujO3JUvEOr7F2p8osZPIY-yi0CsdAPzZSAFICh6SXZs,296448
9
- ormsgpack-1.3.0.dist-info/RECORD,,