ormsgpack 1.3.0__tar.gz → 1.4.1__tar.gz

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.

Files changed (40) hide show
  1. {ormsgpack-1.3.0 → ormsgpack-1.4.1}/CHANGELOG.md +17 -0
  2. {ormsgpack-1.3.0 → ormsgpack-1.4.1}/Cargo.lock +68 -37
  3. {ormsgpack-1.3.0 → ormsgpack-1.4.1}/Cargo.toml +11 -14
  4. {ormsgpack-1.3.0 → ormsgpack-1.4.1}/PKG-INFO +101 -83
  5. {ormsgpack-1.3.0 → ormsgpack-1.4.1}/README.md +100 -82
  6. {ormsgpack-1.3.0 → ormsgpack-1.4.1}/python/ormsgpack/__init__.py +1 -0
  7. {ormsgpack-1.3.0 → ormsgpack-1.4.1}/python/ormsgpack/__init__.pyi +3 -1
  8. {ormsgpack-1.3.0 → ormsgpack-1.4.1}/src/deserialize/cache.rs +1 -1
  9. {ormsgpack-1.3.0 → ormsgpack-1.4.1}/src/deserialize/deserializer.rs +84 -4
  10. ormsgpack-1.4.1/src/ext.rs +79 -0
  11. {ormsgpack-1.3.0 → ormsgpack-1.4.1}/src/ffi.rs +10 -10
  12. {ormsgpack-1.3.0 → ormsgpack-1.4.1}/src/lib.rs +12 -8
  13. {ormsgpack-1.3.0 → ormsgpack-1.4.1}/src/serialize/dataclass.rs +1 -1
  14. {ormsgpack-1.3.0 → ormsgpack-1.4.1}/src/serialize/dict.rs +5 -3
  15. ormsgpack-1.4.1/src/serialize/ext.rs +39 -0
  16. {ormsgpack-1.3.0 → ormsgpack-1.4.1}/src/serialize/mod.rs +1 -0
  17. {ormsgpack-1.3.0 → ormsgpack-1.4.1}/src/serialize/numpy.rs +150 -72
  18. {ormsgpack-1.3.0 → ormsgpack-1.4.1}/src/serialize/serializer.rs +5 -0
  19. {ormsgpack-1.3.0 → ormsgpack-1.4.1}/src/typeref.rs +59 -39
  20. {ormsgpack-1.3.0 → ormsgpack-1.4.1}/src/unicode.rs +7 -7
  21. ormsgpack-1.3.0/src/lazy.rs +0 -66
  22. {ormsgpack-1.3.0 → ormsgpack-1.4.1}/LICENSE-APACHE +0 -0
  23. {ormsgpack-1.3.0 → ormsgpack-1.4.1}/LICENSE-MIT +0 -0
  24. {ormsgpack-1.3.0 → ormsgpack-1.4.1}/build.rs +0 -0
  25. {ormsgpack-1.3.0 → ormsgpack-1.4.1}/pyproject.toml +0 -0
  26. {ormsgpack-1.3.0 → ormsgpack-1.4.1}/python/ormsgpack/py.typed +0 -0
  27. {ormsgpack-1.3.0 → ormsgpack-1.4.1}/src/deserialize/error.rs +0 -0
  28. {ormsgpack-1.3.0 → ormsgpack-1.4.1}/src/deserialize/mod.rs +0 -0
  29. {ormsgpack-1.3.0 → ormsgpack-1.4.1}/src/exc.rs +0 -0
  30. {ormsgpack-1.3.0 → ormsgpack-1.4.1}/src/opt.rs +0 -0
  31. {ormsgpack-1.3.0 → ormsgpack-1.4.1}/src/serialize/bytes.rs +0 -0
  32. {ormsgpack-1.3.0 → ormsgpack-1.4.1}/src/serialize/datetime.rs +0 -0
  33. {ormsgpack-1.3.0 → ormsgpack-1.4.1}/src/serialize/default.rs +0 -0
  34. {ormsgpack-1.3.0 → ormsgpack-1.4.1}/src/serialize/int.rs +0 -0
  35. {ormsgpack-1.3.0 → ormsgpack-1.4.1}/src/serialize/list.rs +0 -0
  36. {ormsgpack-1.3.0 → ormsgpack-1.4.1}/src/serialize/str.rs +0 -0
  37. {ormsgpack-1.3.0 → ormsgpack-1.4.1}/src/serialize/tuple.rs +0 -0
  38. {ormsgpack-1.3.0 → ormsgpack-1.4.1}/src/serialize/uuid.rs +0 -0
  39. {ormsgpack-1.3.0 → ormsgpack-1.4.1}/src/serialize/writer.rs +0 -0
  40. {ormsgpack-1.3.0 → ormsgpack-1.4.1}/src/util.rs +0 -0
@@ -1,5 +1,22 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.4.1 12/11/2023
4
+
5
+ ### Fixed
6
+
7
+ - Fix performance regression in dict serialization introduced in 1.3.0
8
+
9
+ ## 1.4.0 05/11/2023
10
+
11
+ ### Fixed
12
+
13
+ - Fix crash in non optimized builds
14
+
15
+ ### Changed
16
+
17
+ - Add support for MessagePack Extension type
18
+ - Add support for numpy 16-bit integers
19
+
3
20
  ## 1.3.0 04/10/2023
4
21
 
5
22
  ### Changed
@@ -4,13 +4,14 @@ version = 3
4
4
 
5
5
  [[package]]
6
6
  name = "ahash"
7
- version = "0.8.3"
7
+ version = "0.8.6"
8
8
  source = "registry+https://github.com/rust-lang/crates.io-index"
9
- checksum = "2c99f64d1e06488f620f932677e24bc6e2897582980441ae90a671415bd7ec2f"
9
+ checksum = "91429305e9f0a25f6205c5b8e0d2db09e0708a7a6df0f42212bb56c32c8ac97a"
10
10
  dependencies = [
11
11
  "cfg-if",
12
12
  "once_cell",
13
13
  "version_check",
14
+ "zerocopy",
14
15
  ]
15
16
 
16
17
  [[package]]
@@ -33,18 +34,18 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
33
34
 
34
35
  [[package]]
35
36
  name = "bytecount"
36
- version = "0.6.4"
37
+ version = "0.6.7"
37
38
  source = "registry+https://github.com/rust-lang/crates.io-index"
38
- checksum = "ad152d03a2c813c80bb94fedbf3a3f02b28f793e39e7c214c8a0bcc196343de7"
39
+ checksum = "e1e5f035d16fc623ae5f74981db80a439803888314e3a555fd6f04acd51a3205"
39
40
  dependencies = [
40
41
  "packed_simd",
41
42
  ]
42
43
 
43
44
  [[package]]
44
45
  name = "byteorder"
45
- version = "1.4.3"
46
+ version = "1.5.0"
46
47
  source = "registry+https://github.com/rust-lang/crates.io-index"
47
- checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610"
48
+ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b"
48
49
 
49
50
  [[package]]
50
51
  name = "cfg-if"
@@ -70,21 +71,21 @@ checksum = "af150ab688ff2122fcef229be89cb50dd66af9e01a4ff320cc137eecc9bacc38"
70
71
 
71
72
  [[package]]
72
73
  name = "libc"
73
- version = "0.2.148"
74
+ version = "0.2.150"
74
75
  source = "registry+https://github.com/rust-lang/crates.io-index"
75
- checksum = "9cdc71e17332e86d2e1d38c1f99edcb6288ee11b815fb1a4b049eaa2114d369b"
76
+ checksum = "89d92a4743f9a61002fae18374ed11e7973f530cb3a3255fb354818118b2203c"
76
77
 
77
78
  [[package]]
78
79
  name = "libm"
79
- version = "0.2.7"
80
+ version = "0.2.8"
80
81
  source = "registry+https://github.com/rust-lang/crates.io-index"
81
- checksum = "f7012b1bbb0719e1097c47611d3898568c546d597c2e74d66f6087edd5233ff4"
82
+ checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058"
82
83
 
83
84
  [[package]]
84
85
  name = "lock_api"
85
- version = "0.4.10"
86
+ version = "0.4.11"
86
87
  source = "registry+https://github.com/rust-lang/crates.io-index"
87
- checksum = "c1cc9717a20b1bb222f333e6a92fd32f7d8a18ddc5a3191a11af45dcbf4dcd16"
88
+ checksum = "3c168f8615b12bc01f9c17e2eb0cc07dcae1940121185446edc3744920e8ef45"
88
89
  dependencies = [
89
90
  "autocfg",
90
91
  "scopeguard",
@@ -101,9 +102,9 @@ dependencies = [
101
102
 
102
103
  [[package]]
103
104
  name = "num-traits"
104
- version = "0.2.16"
105
+ version = "0.2.17"
105
106
  source = "registry+https://github.com/rust-lang/crates.io-index"
106
- checksum = "f30b0abd723be7e2ffca1272140fac1a2f084c77ec3e123c192b66af1ee9e6c2"
107
+ checksum = "39e3200413f237f41ab11ad6d161bc7239c84dcb631773ccd7de3dfe4b5c267c"
107
108
  dependencies = [
108
109
  "autocfg",
109
110
  "libm",
@@ -117,7 +118,7 @@ checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d"
117
118
 
118
119
  [[package]]
119
120
  name = "ormsgpack"
120
- version = "1.3.0"
121
+ version = "1.4.1"
121
122
  dependencies = [
122
123
  "ahash",
123
124
  "associative-cache",
@@ -130,6 +131,7 @@ dependencies = [
130
131
  "rmp",
131
132
  "rmp-serde",
132
133
  "serde",
134
+ "serde_bytes",
133
135
  "simdutf8",
134
136
  "smallvec",
135
137
  ]
@@ -156,9 +158,9 @@ dependencies = [
156
158
 
157
159
  [[package]]
158
160
  name = "parking_lot_core"
159
- version = "0.9.8"
161
+ version = "0.9.9"
160
162
  source = "registry+https://github.com/rust-lang/crates.io-index"
161
- checksum = "93f00c865fe7cabf650081affecd3871070f26767e7b2070a3ffae14c654b447"
163
+ checksum = "4c42a9226546d68acdd9c0a280d17ce19bfe27a46bf68784e4066115788d008e"
162
164
  dependencies = [
163
165
  "cfg-if",
164
166
  "libc",
@@ -175,18 +177,18 @@ checksum = "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c"
175
177
 
176
178
  [[package]]
177
179
  name = "proc-macro2"
178
- version = "1.0.67"
180
+ version = "1.0.69"
179
181
  source = "registry+https://github.com/rust-lang/crates.io-index"
180
- checksum = "3d433d9f1a3e8c1263d9456598b16fec66f4acc9a74dacffd35c7bb09b3a1328"
182
+ checksum = "134c189feb4956b20f6f547d2cf727d4c0fe06722b20a0eec87ed445a97f92da"
181
183
  dependencies = [
182
184
  "unicode-ident",
183
185
  ]
184
186
 
185
187
  [[package]]
186
188
  name = "pyo3"
187
- version = "0.19.2"
189
+ version = "0.20.0"
188
190
  source = "registry+https://github.com/rust-lang/crates.io-index"
189
- checksum = "e681a6cfdc4adcc93b4d3cf993749a4552018ee0a9b65fc0ccfad74352c72a38"
191
+ checksum = "04e8453b658fe480c3e70c8ed4e3d3ec33eb74988bd186561b0cc66b85c3bc4b"
190
192
  dependencies = [
191
193
  "cfg-if",
192
194
  "libc",
@@ -198,9 +200,9 @@ dependencies = [
198
200
 
199
201
  [[package]]
200
202
  name = "pyo3-build-config"
201
- version = "0.19.2"
203
+ version = "0.20.0"
202
204
  source = "registry+https://github.com/rust-lang/crates.io-index"
203
- checksum = "076c73d0bc438f7a4ef6fdd0c3bb4732149136abd952b110ac93e4edb13a6ba5"
205
+ checksum = "a96fe70b176a89cff78f2fa7b3c930081e163d5379b4dcdf993e3ae29ca662e5"
204
206
  dependencies = [
205
207
  "once_cell",
206
208
  "target-lexicon",
@@ -208,9 +210,9 @@ dependencies = [
208
210
 
209
211
  [[package]]
210
212
  name = "pyo3-ffi"
211
- version = "0.19.2"
213
+ version = "0.20.0"
212
214
  source = "registry+https://github.com/rust-lang/crates.io-index"
213
- checksum = "e53cee42e77ebe256066ba8aa77eff722b3bb91f3419177cf4cd0f304d3284d9"
215
+ checksum = "214929900fd25e6604661ed9cf349727c8920d47deff196c4e28165a6ef2a96b"
214
216
  dependencies = [
215
217
  "libc",
216
218
  "pyo3-build-config",
@@ -227,9 +229,9 @@ dependencies = [
227
229
 
228
230
  [[package]]
229
231
  name = "redox_syscall"
230
- version = "0.3.5"
232
+ version = "0.4.1"
231
233
  source = "registry+https://github.com/rust-lang/crates.io-index"
232
- checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29"
234
+ checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa"
233
235
  dependencies = [
234
236
  "bitflags",
235
237
  ]
@@ -264,18 +266,27 @@ checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"
264
266
 
265
267
  [[package]]
266
268
  name = "serde"
267
- version = "1.0.188"
269
+ version = "1.0.192"
268
270
  source = "registry+https://github.com/rust-lang/crates.io-index"
269
- checksum = "cf9e0fcba69a370eed61bcf2b728575f726b50b55cba78064753d708ddc7549e"
271
+ checksum = "bca2a08484b285dcb282d0f67b26cadc0df8b19f8c12502c13d966bf9482f001"
270
272
  dependencies = [
271
273
  "serde_derive",
272
274
  ]
273
275
 
276
+ [[package]]
277
+ name = "serde_bytes"
278
+ version = "0.11.12"
279
+ source = "registry+https://github.com/rust-lang/crates.io-index"
280
+ checksum = "ab33ec92f677585af6d88c65593ae2375adde54efdbf16d597f2cbc7a6d368ff"
281
+ dependencies = [
282
+ "serde",
283
+ ]
284
+
274
285
  [[package]]
275
286
  name = "serde_derive"
276
- version = "1.0.188"
287
+ version = "1.0.192"
277
288
  source = "registry+https://github.com/rust-lang/crates.io-index"
278
- checksum = "4eca7ac642d82aa35b60049a6eccb4be6be75e599bd2e9adb5f875a737654af2"
289
+ checksum = "d6c7207fbec9faa48073f3e3074cbe553af6ea512d7c21ba46e434e70ea9fbc1"
279
290
  dependencies = [
280
291
  "proc-macro2",
281
292
  "quote",
@@ -290,15 +301,15 @@ checksum = "f27f6278552951f1f2b8cf9da965d10969b2efdea95a6ec47987ab46edfe263a"
290
301
 
291
302
  [[package]]
292
303
  name = "smallvec"
293
- version = "1.11.1"
304
+ version = "1.11.2"
294
305
  source = "registry+https://github.com/rust-lang/crates.io-index"
295
- checksum = "942b4a808e05215192e39f4ab80813e599068285906cc91aa64f923db842bd5a"
306
+ checksum = "4dccd0940a2dcdf68d092b8cbab7dc0ad8fa938bf95787e1b916b0e3d0e8e970"
296
307
 
297
308
  [[package]]
298
309
  name = "syn"
299
- version = "2.0.37"
310
+ version = "2.0.38"
300
311
  source = "registry+https://github.com/rust-lang/crates.io-index"
301
- checksum = "7303ef2c05cd654186cb250d29049a24840ca25d2747c25c0381c8d9e2f582e8"
312
+ checksum = "e96b79aaa137db8f61e26363a0c9b47d8b4ec75da28b7d1d614c2303e232408b"
302
313
  dependencies = [
303
314
  "proc-macro2",
304
315
  "quote",
@@ -307,9 +318,9 @@ dependencies = [
307
318
 
308
319
  [[package]]
309
320
  name = "target-lexicon"
310
- version = "0.12.11"
321
+ version = "0.12.12"
311
322
  source = "registry+https://github.com/rust-lang/crates.io-index"
312
- checksum = "9d0e916b1148c8e263850e1ebcbd046f333e0683c724876bb0da63ea4373dc8a"
323
+ checksum = "14c39fd04924ca3a864207c66fc2cd7d22d7c016007f9ce846cbb9326331930a"
313
324
 
314
325
  [[package]]
315
326
  name = "unicode-ident"
@@ -379,3 +390,23 @@ name = "windows_x86_64_msvc"
379
390
  version = "0.48.5"
380
391
  source = "registry+https://github.com/rust-lang/crates.io-index"
381
392
  checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538"
393
+
394
+ [[package]]
395
+ name = "zerocopy"
396
+ version = "0.7.25"
397
+ source = "registry+https://github.com/rust-lang/crates.io-index"
398
+ checksum = "8cd369a67c0edfef15010f980c3cbe45d7f651deac2cd67ce097cd801de16557"
399
+ dependencies = [
400
+ "zerocopy-derive",
401
+ ]
402
+
403
+ [[package]]
404
+ name = "zerocopy-derive"
405
+ version = "0.7.25"
406
+ source = "registry+https://github.com/rust-lang/crates.io-index"
407
+ checksum = "c2f140bda219a26ccc0cdb03dba58af72590c53b22642577d88a927bc5c87d6b"
408
+ dependencies = [
409
+ "proc-macro2",
410
+ "quote",
411
+ "syn",
412
+ ]
@@ -1,6 +1,6 @@
1
1
  [package]
2
2
  name = "ormsgpack"
3
- version = "1.3.0"
3
+ version = "1.4.1"
4
4
  authors = [
5
5
  "Aviram Hassan <aviramyhassan@gmail.com>",
6
6
  "Emanuele Giaquinta <emanuele.giaquinta@gmail.com>",
@@ -33,29 +33,26 @@ default = ["unstable-simd"]
33
33
  # Use SIMD intrinsics. This requires Rust on the nightly channel.
34
34
  unstable-simd = [
35
35
  "bytecount/generic-simd",
36
- "bytecount/runtime-dispatch-simd",
37
36
  "encoding_rs/simd-accel",
38
- "simdutf8/aarch64_neon",
39
- "simdutf8/std",
40
37
  ]
41
38
 
42
39
  [dependencies]
43
40
  ahash = { version = "0.8", default_features = false }
44
- associative-cache = { version = "2" }
45
- bytecount = { version = "^0.6.2", default_features = false, features = ["runtime-dispatch-simd"] }
41
+ associative-cache = { version = "2", default_features = false }
42
+ bytecount = { version = "^0.6.7", default_features = false, features = ["runtime-dispatch-simd"] }
46
43
  encoding_rs = { version = "0.8", default_features = false }
47
44
  itoa = { version = "1", default_features = false }
48
- once_cell = { version = "1", default_features = false }
49
- pyo3 = { version = "0.19.2", default_features = false, features = ["extension-module"]}
45
+ once_cell = { version = "1", default_features = false, features = ["race"] }
46
+ pyo3 = { version = "^0.20.0", default_features = false, features = ["extension-module"] }
47
+ rmp = { version = "^0.8.10", default_features = false, features = ["std"] }
48
+ rmp-serde = { version = "1", default_features = false }
50
49
  serde = { version = "1", default_features = false }
51
- simdutf8 = { version = "0.1", default_features = false, features = ["std"] }
52
- smallvec = { version = "^1.8", default_features = false, features = ["union", "write"] }
53
- rmp = { version = "^0.8.10"}
54
- rmp-serde = {version = "1"}
55
-
50
+ serde_bytes = { version = "0.11.12", default_features = false, features = ["std"] }
51
+ simdutf8 = { version = "0.1", default_features = false, features = ["std", "aarch64_neon"] }
52
+ smallvec = { version = "^1.11", default_features = false, features = ["union", "write"] }
56
53
 
57
54
  [build-dependencies]
58
- pyo3-build-config = { version = "0.19.2" }
55
+ pyo3-build-config = { version = "^0.20.0" }
59
56
 
60
57
  [profile.release]
61
58
  codegen-units = 1
@@ -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