ormsgpack 1.7.0__tar.gz → 1.8.0__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 (41) hide show
  1. {ormsgpack-1.7.0 → ormsgpack-1.8.0}/CHANGELOG.md +11 -0
  2. {ormsgpack-1.7.0 → ormsgpack-1.8.0}/Cargo.lock +43 -43
  3. {ormsgpack-1.7.0 → ormsgpack-1.8.0}/Cargo.toml +5 -4
  4. {ormsgpack-1.7.0 → ormsgpack-1.8.0}/PKG-INFO +31 -31
  5. {ormsgpack-1.7.0 → ormsgpack-1.8.0}/README.md +30 -30
  6. {ormsgpack-1.7.0 → ormsgpack-1.8.0}/pyproject.toml +18 -1
  7. {ormsgpack-1.7.0 → ormsgpack-1.8.0}/python/ormsgpack/__init__.py +2 -0
  8. {ormsgpack-1.7.0 → ormsgpack-1.8.0}/python/ormsgpack/__init__.pyi +1 -0
  9. {ormsgpack-1.7.0 → ormsgpack-1.8.0}/src/deserialize/deserializer.rs +3 -3
  10. {ormsgpack-1.7.0 → ormsgpack-1.8.0}/src/lib.rs +59 -69
  11. {ormsgpack-1.7.0 → ormsgpack-1.8.0}/src/opt.rs +7 -4
  12. {ormsgpack-1.7.0 → ormsgpack-1.8.0}/src/serialize/dataclass.rs +2 -2
  13. {ormsgpack-1.7.0 → ormsgpack-1.8.0}/src/serialize/datetime.rs +4 -4
  14. {ormsgpack-1.7.0 → ormsgpack-1.8.0}/src/serialize/dict.rs +4 -23
  15. ormsgpack-1.8.0/src/serialize/numpy.rs +591 -0
  16. {ormsgpack-1.7.0 → ormsgpack-1.8.0}/src/serialize/serializer.rs +343 -203
  17. {ormsgpack-1.7.0 → ormsgpack-1.8.0}/src/typeref.rs +10 -21
  18. {ormsgpack-1.7.0 → ormsgpack-1.8.0}/src/util.rs +3 -36
  19. ormsgpack-1.7.0/src/serialize/numpy.rs +0 -932
  20. {ormsgpack-1.7.0 → ormsgpack-1.8.0}/LICENSE-APACHE +0 -0
  21. {ormsgpack-1.7.0 → ormsgpack-1.8.0}/LICENSE-MIT +0 -0
  22. {ormsgpack-1.7.0 → ormsgpack-1.8.0}/build.rs +0 -0
  23. {ormsgpack-1.7.0 → ormsgpack-1.8.0}/python/ormsgpack/py.typed +0 -0
  24. {ormsgpack-1.7.0 → ormsgpack-1.8.0}/src/deserialize/cache.rs +0 -0
  25. {ormsgpack-1.7.0 → ormsgpack-1.8.0}/src/deserialize/error.rs +0 -0
  26. {ormsgpack-1.7.0 → ormsgpack-1.8.0}/src/deserialize/mod.rs +0 -0
  27. {ormsgpack-1.7.0 → ormsgpack-1.8.0}/src/exc.rs +0 -0
  28. {ormsgpack-1.7.0 → ormsgpack-1.8.0}/src/ext.rs +0 -0
  29. {ormsgpack-1.7.0 → ormsgpack-1.8.0}/src/ffi.rs +0 -0
  30. {ormsgpack-1.7.0 → ormsgpack-1.8.0}/src/serialize/bytes.rs +0 -0
  31. {ormsgpack-1.7.0 → ormsgpack-1.8.0}/src/serialize/datetimelike.rs +0 -0
  32. {ormsgpack-1.7.0 → ormsgpack-1.8.0}/src/serialize/default.rs +0 -0
  33. {ormsgpack-1.7.0 → ormsgpack-1.8.0}/src/serialize/ext.rs +0 -0
  34. {ormsgpack-1.7.0 → ormsgpack-1.8.0}/src/serialize/int.rs +0 -0
  35. {ormsgpack-1.7.0 → ormsgpack-1.8.0}/src/serialize/list.rs +0 -0
  36. {ormsgpack-1.7.0 → ormsgpack-1.8.0}/src/serialize/mod.rs +0 -0
  37. {ormsgpack-1.7.0 → ormsgpack-1.8.0}/src/serialize/str.rs +0 -0
  38. {ormsgpack-1.7.0 → ormsgpack-1.8.0}/src/serialize/tuple.rs +0 -0
  39. {ormsgpack-1.7.0 → ormsgpack-1.8.0}/src/serialize/uuid.rs +0 -0
  40. {ormsgpack-1.7.0 → ormsgpack-1.8.0}/src/serialize/writer.rs +0 -0
  41. {ormsgpack-1.7.0 → ormsgpack-1.8.0}/src/unicode.rs +0 -0
@@ -1,5 +1,16 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.8.0 22/02/2025
4
+
5
+ ### Fixed
6
+
7
+ - `packb` now rejects dictionary keys with nested dataclasses or pydantic models
8
+
9
+ ### Changed
10
+
11
+ - Add `packb` option `OPT_PASSTHROUGH_UUID` to enable passthrough of UUID objects [#338](/../../issues/338)
12
+ - Update dependencies
13
+
3
14
  ## 1.7.0 29/11/2024
4
15
 
5
16
  ### Fixed
@@ -16,9 +16,9 @@ dependencies = [
16
16
 
17
17
  [[package]]
18
18
  name = "autocfg"
19
- version = "1.3.0"
19
+ version = "1.4.0"
20
20
  source = "registry+https://github.com/rust-lang/crates.io-index"
21
- checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0"
21
+ checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26"
22
22
 
23
23
  [[package]]
24
24
  name = "bytecount"
@@ -40,18 +40,18 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
40
40
 
41
41
  [[package]]
42
42
  name = "chrono"
43
- version = "0.4.38"
43
+ version = "0.4.39"
44
44
  source = "registry+https://github.com/rust-lang/crates.io-index"
45
- checksum = "a21f936df1771bf62b77f047b726c4625ff2e8aa607c01ec06e5a05bd8463401"
45
+ checksum = "7e36cc9d416881d2e24f9a963be5fb1cd90966419ac844274161d10488b3e825"
46
46
  dependencies = [
47
47
  "num-traits",
48
48
  ]
49
49
 
50
50
  [[package]]
51
51
  name = "crunchy"
52
- version = "0.2.2"
52
+ version = "0.2.3"
53
53
  source = "registry+https://github.com/rust-lang/crates.io-index"
54
- checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7"
54
+ checksum = "43da5946c66ffcc7745f48db692ffbb10a83bfe0afd96235c5c2a4fb23994929"
55
55
 
56
56
  [[package]]
57
57
  name = "half"
@@ -65,15 +65,15 @@ dependencies = [
65
65
 
66
66
  [[package]]
67
67
  name = "itoa"
68
- version = "1.0.13"
68
+ version = "1.0.14"
69
69
  source = "registry+https://github.com/rust-lang/crates.io-index"
70
- checksum = "540654e97a3f4470a492cd30ff187bc95d89557a903a2bbf112e2fae98104ef2"
70
+ checksum = "d75a2a4b1b190afb6f5425f10f6a8f959d2ea0b9c2b1d79553551850539e4674"
71
71
 
72
72
  [[package]]
73
73
  name = "libc"
74
- version = "0.2.154"
74
+ version = "0.2.169"
75
75
  source = "registry+https://github.com/rust-lang/crates.io-index"
76
- checksum = "ae743338b92ff9146ce83992f766a31066a91a8c84a45e0e9f21e7cf6de6d346"
76
+ checksum = "b5aba8db14291edd000dfcc4d620c7ebfb122c613afb886ca8803fa4e128a20a"
77
77
 
78
78
  [[package]]
79
79
  name = "memoffset"
@@ -95,13 +95,13 @@ dependencies = [
95
95
 
96
96
  [[package]]
97
97
  name = "once_cell"
98
- version = "1.20.2"
98
+ version = "1.20.3"
99
99
  source = "registry+https://github.com/rust-lang/crates.io-index"
100
- checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775"
100
+ checksum = "945462a4b81e43c4e3ba96bd7b49d834c6f61198356aa858733bc4acf3cbe62e"
101
101
 
102
102
  [[package]]
103
103
  name = "ormsgpack"
104
- version = "1.7.0"
104
+ version = "1.8.0"
105
105
  dependencies = [
106
106
  "ahash",
107
107
  "bytecount",
@@ -127,24 +127,24 @@ checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a"
127
127
 
128
128
  [[package]]
129
129
  name = "portable-atomic"
130
- version = "1.6.0"
130
+ version = "1.10.0"
131
131
  source = "registry+https://github.com/rust-lang/crates.io-index"
132
- checksum = "7170ef9988bc169ba16dd36a7fa041e5c4cbeb6a35b76d4c03daded371eae7c0"
132
+ checksum = "280dc24453071f1b63954171985a0b0d30058d287960968b9b2aca264c8d4ee6"
133
133
 
134
134
  [[package]]
135
135
  name = "proc-macro2"
136
- version = "1.0.89"
136
+ version = "1.0.93"
137
137
  source = "registry+https://github.com/rust-lang/crates.io-index"
138
- checksum = "f139b0662de085916d1fb67d2b4169d1addddda1919e696f3252b740b629986e"
138
+ checksum = "60946a68e5f9d28b0dc1c21bb8a97ee7d018a8b322fa57838ba31cc878e22d99"
139
139
  dependencies = [
140
140
  "unicode-ident",
141
141
  ]
142
142
 
143
143
  [[package]]
144
144
  name = "pyo3"
145
- version = "0.22.6"
145
+ version = "0.23.4"
146
146
  source = "registry+https://github.com/rust-lang/crates.io-index"
147
- checksum = "f402062616ab18202ae8319da13fa4279883a2b8a9d9f83f20dbade813ce1884"
147
+ checksum = "57fe09249128b3173d092de9523eaa75136bf7ba85e0d69eca241c7939c933cc"
148
148
  dependencies = [
149
149
  "cfg-if",
150
150
  "libc",
@@ -157,9 +157,9 @@ dependencies = [
157
157
 
158
158
  [[package]]
159
159
  name = "pyo3-build-config"
160
- version = "0.22.6"
160
+ version = "0.23.4"
161
161
  source = "registry+https://github.com/rust-lang/crates.io-index"
162
- checksum = "b14b5775b5ff446dd1056212d778012cbe8a0fbffd368029fd9e25b514479c38"
162
+ checksum = "1cd3927b5a78757a0d71aa9dff669f903b1eb64b54142a9bd9f757f8fde65fd7"
163
163
  dependencies = [
164
164
  "once_cell",
165
165
  "target-lexicon",
@@ -167,9 +167,9 @@ dependencies = [
167
167
 
168
168
  [[package]]
169
169
  name = "pyo3-ffi"
170
- version = "0.22.6"
170
+ version = "0.23.4"
171
171
  source = "registry+https://github.com/rust-lang/crates.io-index"
172
- checksum = "9ab5bcf04a2cdcbb50c7d6105de943f543f9ed92af55818fd17b660390fc8636"
172
+ checksum = "dab6bb2102bd8f991e7749f130a70d05dd557613e39ed2deeee8e9ca0c4d548d"
173
173
  dependencies = [
174
174
  "libc",
175
175
  "pyo3-build-config",
@@ -177,9 +177,9 @@ dependencies = [
177
177
 
178
178
  [[package]]
179
179
  name = "quote"
180
- version = "1.0.36"
180
+ version = "1.0.38"
181
181
  source = "registry+https://github.com/rust-lang/crates.io-index"
182
- checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7"
182
+ checksum = "0e4dccaaaf89514f546c693ddc140f729f958c247918a13380cccc6078391acc"
183
183
  dependencies = [
184
184
  "proc-macro2",
185
185
  ]
@@ -197,9 +197,9 @@ dependencies = [
197
197
 
198
198
  [[package]]
199
199
  name = "serde"
200
- version = "1.0.215"
200
+ version = "1.0.218"
201
201
  source = "registry+https://github.com/rust-lang/crates.io-index"
202
- checksum = "6513c1ad0b11a9376da888e3e0baa0077f1aed55c17f50e7b2397136129fb88f"
202
+ checksum = "e8dfc9d19bdbf6d17e22319da49161d5d0108e4188e8b680aef6299eed22df60"
203
203
  dependencies = [
204
204
  "serde_derive",
205
205
  ]
@@ -215,9 +215,9 @@ dependencies = [
215
215
 
216
216
  [[package]]
217
217
  name = "serde_derive"
218
- version = "1.0.215"
218
+ version = "1.0.218"
219
219
  source = "registry+https://github.com/rust-lang/crates.io-index"
220
- checksum = "ad1e866f866923f252f05c889987993144fb74e722403468a4ebd70c3cd756c0"
220
+ checksum = "f09503e191f4e797cb8aac08e9a4a4695c5edf6a2e70e376d961ddd5c969f82b"
221
221
  dependencies = [
222
222
  "proc-macro2",
223
223
  "quote",
@@ -232,15 +232,15 @@ checksum = "e3a9fe34e3e7a50316060351f37187a3f546bce95496156754b601a5fa71b76e"
232
232
 
233
233
  [[package]]
234
234
  name = "smallvec"
235
- version = "1.13.2"
235
+ version = "1.14.0"
236
236
  source = "registry+https://github.com/rust-lang/crates.io-index"
237
- checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67"
237
+ checksum = "7fcf8323ef1faaee30a44a340193b1ac6814fd9b7b4e88e9d4519a3e4abe1cfd"
238
238
 
239
239
  [[package]]
240
240
  name = "syn"
241
- version = "2.0.82"
241
+ version = "2.0.98"
242
242
  source = "registry+https://github.com/rust-lang/crates.io-index"
243
- checksum = "83540f837a8afc019423a8edb95b52a8effe46957ee402287f4292fae35be021"
243
+ checksum = "36147f1a48ae0ec2b5b3bc5b537d267457555a10dc06f3dbc8cb11ba3006d3b1"
244
244
  dependencies = [
245
245
  "proc-macro2",
246
246
  "quote",
@@ -249,36 +249,36 @@ dependencies = [
249
249
 
250
250
  [[package]]
251
251
  name = "target-lexicon"
252
- version = "0.12.14"
252
+ version = "0.12.16"
253
253
  source = "registry+https://github.com/rust-lang/crates.io-index"
254
- checksum = "e1fc403891a21bcfb7c37834ba66a547a8f402146eba7265b5a6d88059c9ff2f"
254
+ checksum = "61c41af27dd6d1e27b1b16b489db798443478cef1f06a660c96db617ba5de3b1"
255
255
 
256
256
  [[package]]
257
257
  name = "unicode-ident"
258
- version = "1.0.12"
258
+ version = "1.0.17"
259
259
  source = "registry+https://github.com/rust-lang/crates.io-index"
260
- checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b"
260
+ checksum = "00e2473a93778eb0bad35909dff6a10d28e63f792f16ed15e404fca9d5eeedbe"
261
261
 
262
262
  [[package]]
263
263
  name = "version_check"
264
- version = "0.9.4"
264
+ version = "0.9.5"
265
265
  source = "registry+https://github.com/rust-lang/crates.io-index"
266
- checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f"
266
+ checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a"
267
267
 
268
268
  [[package]]
269
269
  name = "zerocopy"
270
- version = "0.7.34"
270
+ version = "0.7.35"
271
271
  source = "registry+https://github.com/rust-lang/crates.io-index"
272
- checksum = "ae87e3fcd617500e5d106f0380cf7b77f3c6092aae37191433159dda23cfb087"
272
+ checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0"
273
273
  dependencies = [
274
274
  "zerocopy-derive",
275
275
  ]
276
276
 
277
277
  [[package]]
278
278
  name = "zerocopy-derive"
279
- version = "0.7.34"
279
+ version = "0.7.35"
280
280
  source = "registry+https://github.com/rust-lang/crates.io-index"
281
- checksum = "15e934569e47891f7d9411f1a451d947a60e000ab3bd24fbb970f000387d1b3b"
281
+ checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e"
282
282
  dependencies = [
283
283
  "proc-macro2",
284
284
  "quote",
@@ -1,6 +1,6 @@
1
1
  [package]
2
2
  name = "ormsgpack"
3
- version = "1.7.0"
3
+ version = "1.8.0"
4
4
  authors = [
5
5
  "Aviram Hassan <aviramyhassan@gmail.com>",
6
6
  "Emanuele Giaquinta <emanuele.giaquinta@gmail.com>",
@@ -40,11 +40,11 @@ unstable-simd = [
40
40
  ahash = { version = "0.8", default-features = false }
41
41
  bytecount = { version = "^0.6.7", default-features = false, features = ["runtime-dispatch-simd"] }
42
42
  byteorder = { version = "1.5.0", default-features = false, features = ["std"] }
43
- chrono = { version = "0.4.38", default-features = false }
43
+ chrono = { version = "0.4.39", default-features = false }
44
44
  half = { version = "2.4.1", default-features = false }
45
45
  itoa = { version = "1", default-features = false }
46
46
  once_cell = { version = "1", default-features = false, features = ["race"] }
47
- pyo3 = { version = "^0.22.6", default-features = false, features = ["extension-module"] }
47
+ pyo3 = { version = "^0.23.4", default-features = false, features = ["extension-module"] }
48
48
  rmp = { version = "^0.8.14", default-features = false, features = ["std"] }
49
49
  serde = { version = "1", default-features = false }
50
50
  serde_bytes = { version = "0.11.15", default-features = false, features = ["std"] }
@@ -52,7 +52,7 @@ simdutf8 = { version = "0.1.5", default-features = false, features = ["std"] }
52
52
  smallvec = { version = "^1.13", default-features = false, features = ["union", "write"] }
53
53
 
54
54
  [build-dependencies]
55
- pyo3-build-config = { version = "^0.22.0" }
55
+ pyo3-build-config = { version = "^0.23.3" }
56
56
 
57
57
  [profile.release]
58
58
  codegen-units = 1
@@ -61,3 +61,4 @@ incremental = false
61
61
  lto = "thin"
62
62
  opt-level = 3
63
63
  panic = "abort"
64
+ strip = "symbols"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ormsgpack
3
- Version: 1.7.0
3
+ Version: 1.8.0
4
4
  Classifier: Development Status :: 5 - Production/Stable
5
5
  Classifier: Intended Audience :: Developers
6
6
  Classifier: License :: OSI Approved :: Apache Software License
@@ -120,8 +120,7 @@ It natively serializes
120
120
  `None` instances. It supports arbitrary types through `default`. It
121
121
  serializes subclasses of `str`, `int`, `dict`, `list`,
122
122
  `dataclasses.dataclass`, and `enum.Enum`. It does not serialize subclasses
123
- of `tuple` to avoid serializing `namedtuple` objects as arrays. To avoid
124
- serializing subclasses, specify the option `ormsgpack.OPT_PASSTHROUGH_SUBCLASS`.
123
+ of `tuple` to avoid serializing `namedtuple` objects as arrays.
125
124
 
126
125
  The output is a `bytes` object.
127
126
 
@@ -205,13 +204,16 @@ value, respectively.
205
204
  b'\xc7\x18\x000.0842389659712649442845'
206
205
  ```
207
206
 
207
+ `default` can also be used to serialize some supported types to a custom
208
+ format by enabling the corresponding passthrough options.
209
+
208
210
  #### option
209
211
 
210
212
  To modify how data is serialized, specify `option`. Each `option` is an integer
211
213
  constant in `ormsgpack`. To specify multiple options, mask them together, e.g.,
212
214
  `option=ormsgpack.OPT_NON_STR_KEYS | ormsgpack.OPT_NAIVE_UTC`.
213
215
 
214
- ##### OPT_NAIVE_UTC
216
+ ##### `OPT_NAIVE_UTC`
215
217
 
216
218
  Serialize `datetime.datetime` objects without a `tzinfo` and `numpy.datetime64`
217
219
  objects as UTC. This has no effect on `datetime.datetime` objects that have
@@ -234,11 +236,13 @@ b'\xb91970-01-01T00:00:00+00:00'
234
236
  '1970-01-01T00:00:00+00:00'
235
237
  ```
236
238
 
237
- ##### OPT_NON_STR_KEYS
239
+ ##### `OPT_NON_STR_KEYS`
238
240
 
239
241
  Serialize `dict` keys of type other than `str`. This allows `dict` keys
240
242
  to be one of `str`, `int`, `float`, `bool`, `None`, `datetime.datetime`,
241
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.
242
246
 
243
247
  ```python
244
248
  >>> import ormsgpack, datetime, uuid
@@ -270,7 +274,7 @@ occurrence of a key (in the above, `false`). The first value will be lost.
270
274
 
271
275
  This option is not compatible with `ormsgpack.OPT_SORT_KEYS`.
272
276
 
273
- ##### OPT_OMIT_MICROSECONDS
277
+ ##### `OPT_OMIT_MICROSECONDS`
274
278
 
275
279
  Do not serialize the microsecond component of `datetime.datetime`,
276
280
  `datetime.time` and `numpy.datetime64` instances.
@@ -292,9 +296,10 @@ b'\xb31970-01-01T00:00:00'
292
296
  '1970-01-01T00:00:00'
293
297
  ```
294
298
 
295
- ##### OPT_PASSTHROUGH_BIG_INT
299
+ ##### `OPT_PASSTHROUGH_BIG_INT`
296
300
 
297
- Enables passthrough of big (Python) ints. By setting this option, one can set a `default` function for ints larger than 63 bits, smaller ints are still serialized efficiently.
301
+ Enable passthrough of `int` instances smaller than -9223372036854775807 or
302
+ larger than 18446744073709551615 to `default`.
298
303
 
299
304
  ```python
300
305
  >>> import ormsgpack
@@ -312,10 +317,9 @@ b'\x82\xa4type\xa6bigint\xa5value\xb436893488147419103232'
312
317
  {'type': 'bigint', 'value': '36893488147419103232'}
313
318
  ```
314
319
 
315
- ##### OPT_PASSTHROUGH_DATACLASS
320
+ ##### `OPT_PASSTHROUGH_DATACLASS`
316
321
 
317
- Passthrough `dataclasses.dataclass` instances to `default`. This allows
318
- customizing their output but is much slower.
322
+ Enable passthrough of `dataclasses.dataclass` instances to `default`.
319
323
 
320
324
 
321
325
  ```python
@@ -343,11 +347,10 @@ TypeError: Type is not msgpack serializable: User
343
347
  b'\x82\xa2id\xa33b1\xa4name\xa3asd'
344
348
  ```
345
349
 
346
- ##### OPT_PASSTHROUGH_DATETIME
350
+ ##### `OPT_PASSTHROUGH_DATETIME`
347
351
 
348
- Passthrough `datetime.datetime`, `datetime.date`, and `datetime.time` instances
349
- to `default`. This allows serializing datetimes to a custom format, e.g.,
350
- HTTP dates:
352
+ Enable passthrough of `datetime.datetime`, `datetime.date`, and
353
+ `datetime.time` instances to `default`.
351
354
 
352
355
  ```python
353
356
  >>> import ormsgpack, datetime
@@ -368,11 +371,10 @@ TypeError: Type is not msgpack serializable: datetime.datetime
368
371
  b'\x81\xaacreated_at\xbdThu, 01 Jan 1970 00:00:00 GMT'
369
372
  ```
370
373
 
371
- This does not affect datetimes in `dict` keys if using OPT_NON_STR_KEYS.
372
-
373
- ##### OPT_PASSTHROUGH_SUBCLASS
374
+ ##### `OPT_PASSTHROUGH_SUBCLASS`
374
375
 
375
- Passthrough subclasses of builtin types to `default`.
376
+ Enable passthrough of subclasses of `str`, `int`, `dict` and `list` to
377
+ `default`.
376
378
 
377
379
  ```python
378
380
  >>> import ormsgpack
@@ -392,12 +394,9 @@ TypeError: Type is not msgpack serializable: Secret
392
394
  b'\xa6******'
393
395
  ```
394
396
 
395
- This does not affect serializing subclasses as `dict` keys if using
396
- OPT_NON_STR_KEYS.
397
-
398
- ##### OPT_PASSTHROUGH_TUPLE
397
+ ##### `OPT_PASSTHROUGH_TUPLE`
399
398
 
400
- Passthrough tuples to `default`.
399
+ Enable passthrough of `tuple` instances to `default`.
401
400
 
402
401
  ```python
403
402
  >>> import ormsgpack
@@ -417,15 +416,19 @@ b'\x82\xa4type\xa5tuple\xa5value\x93\xcd#\xe9\xa4test*'
417
416
  {'type': 'tuple', 'value': [9193, 'test', 42]}
418
417
  ```
419
418
 
420
- ##### OPT_SERIALIZE_NUMPY
419
+ ##### `OPT_PASSTHROUGH_UUID`
420
+
421
+ Enable passthrough of `uuid.UUID` instances to `default`.
422
+
423
+ ##### `OPT_SERIALIZE_NUMPY`
421
424
 
422
425
  Serialize `numpy.ndarray` instances. For more, see
423
426
  [numpy](#numpy).
424
427
 
425
- ##### OPT_SERIALIZE_PYDANTIC
428
+ ##### `OPT_SERIALIZE_PYDANTIC`
426
429
  Serialize `pydantic.BaseModel` instances.
427
430
 
428
- ##### OPT_SORT_KEYS
431
+ ##### `OPT_SORT_KEYS`
429
432
 
430
433
  Serialize `dict` keys and pydantic model fields in sorted order. The default
431
434
  is to serialize in an unspecified order.
@@ -451,7 +454,7 @@ b'\x83\xa1A\x03\xa1a\x01\xa2\xc3\xa4\x02'
451
454
 
452
455
  `dataclass` also serialize as maps but this has no effect on them.
453
456
 
454
- ##### OPT_UTC_Z
457
+ ##### `OPT_UTC_Z`
455
458
 
456
459
  Serialize a UTC timezone on `datetime.datetime` and `numpy.datetime64` instances
457
460
  as `Z` instead of `+00:00`.
@@ -620,9 +623,6 @@ b'\xaa1900-01-02'
620
623
 
621
624
  Errors with `tzinfo` result in `MsgpackEncodeError` being raised.
622
625
 
623
- To disable serialization of `datetime` objects specify the option
624
- `ormsgpack.OPT_PASSTHROUGH_DATETIME`.
625
-
626
626
  To use "Z" suffix instead of "+00:00" to indicate UTC ("Zulu") time, use the option
627
627
  `ormsgpack.OPT_UTC_Z`.
628
628
 
@@ -88,8 +88,7 @@ It natively serializes
88
88
  `None` instances. It supports arbitrary types through `default`. It
89
89
  serializes subclasses of `str`, `int`, `dict`, `list`,
90
90
  `dataclasses.dataclass`, and `enum.Enum`. It does not serialize subclasses
91
- of `tuple` to avoid serializing `namedtuple` objects as arrays. To avoid
92
- serializing subclasses, specify the option `ormsgpack.OPT_PASSTHROUGH_SUBCLASS`.
91
+ of `tuple` to avoid serializing `namedtuple` objects as arrays.
93
92
 
94
93
  The output is a `bytes` object.
95
94
 
@@ -173,13 +172,16 @@ value, respectively.
173
172
  b'\xc7\x18\x000.0842389659712649442845'
174
173
  ```
175
174
 
175
+ `default` can also be used to serialize some supported types to a custom
176
+ format by enabling the corresponding passthrough options.
177
+
176
178
  #### option
177
179
 
178
180
  To modify how data is serialized, specify `option`. Each `option` is an integer
179
181
  constant in `ormsgpack`. To specify multiple options, mask them together, e.g.,
180
182
  `option=ormsgpack.OPT_NON_STR_KEYS | ormsgpack.OPT_NAIVE_UTC`.
181
183
 
182
- ##### OPT_NAIVE_UTC
184
+ ##### `OPT_NAIVE_UTC`
183
185
 
184
186
  Serialize `datetime.datetime` objects without a `tzinfo` and `numpy.datetime64`
185
187
  objects as UTC. This has no effect on `datetime.datetime` objects that have
@@ -202,11 +204,13 @@ b'\xb91970-01-01T00:00:00+00:00'
202
204
  '1970-01-01T00:00:00+00:00'
203
205
  ```
204
206
 
205
- ##### OPT_NON_STR_KEYS
207
+ ##### `OPT_NON_STR_KEYS`
206
208
 
207
209
  Serialize `dict` keys of type other than `str`. This allows `dict` keys
208
210
  to be one of `str`, `int`, `float`, `bool`, `None`, `datetime.datetime`,
209
211
  `datetime.date`, `datetime.time`, `enum.Enum`, and `uuid.UUID`.
212
+ `dict` keys of unsupported types are not handled using `default` and
213
+ result in `MsgpackEncodeError` being raised.
210
214
 
211
215
  ```python
212
216
  >>> import ormsgpack, datetime, uuid
@@ -238,7 +242,7 @@ occurrence of a key (in the above, `false`). The first value will be lost.
238
242
 
239
243
  This option is not compatible with `ormsgpack.OPT_SORT_KEYS`.
240
244
 
241
- ##### OPT_OMIT_MICROSECONDS
245
+ ##### `OPT_OMIT_MICROSECONDS`
242
246
 
243
247
  Do not serialize the microsecond component of `datetime.datetime`,
244
248
  `datetime.time` and `numpy.datetime64` instances.
@@ -260,9 +264,10 @@ b'\xb31970-01-01T00:00:00'
260
264
  '1970-01-01T00:00:00'
261
265
  ```
262
266
 
263
- ##### OPT_PASSTHROUGH_BIG_INT
267
+ ##### `OPT_PASSTHROUGH_BIG_INT`
264
268
 
265
- Enables passthrough of big (Python) ints. By setting this option, one can set a `default` function for ints larger than 63 bits, smaller ints are still serialized efficiently.
269
+ Enable passthrough of `int` instances smaller than -9223372036854775807 or
270
+ larger than 18446744073709551615 to `default`.
266
271
 
267
272
  ```python
268
273
  >>> import ormsgpack
@@ -280,10 +285,9 @@ b'\x82\xa4type\xa6bigint\xa5value\xb436893488147419103232'
280
285
  {'type': 'bigint', 'value': '36893488147419103232'}
281
286
  ```
282
287
 
283
- ##### OPT_PASSTHROUGH_DATACLASS
288
+ ##### `OPT_PASSTHROUGH_DATACLASS`
284
289
 
285
- Passthrough `dataclasses.dataclass` instances to `default`. This allows
286
- customizing their output but is much slower.
290
+ Enable passthrough of `dataclasses.dataclass` instances to `default`.
287
291
 
288
292
 
289
293
  ```python
@@ -311,11 +315,10 @@ TypeError: Type is not msgpack serializable: User
311
315
  b'\x82\xa2id\xa33b1\xa4name\xa3asd'
312
316
  ```
313
317
 
314
- ##### OPT_PASSTHROUGH_DATETIME
318
+ ##### `OPT_PASSTHROUGH_DATETIME`
315
319
 
316
- Passthrough `datetime.datetime`, `datetime.date`, and `datetime.time` instances
317
- to `default`. This allows serializing datetimes to a custom format, e.g.,
318
- HTTP dates:
320
+ Enable passthrough of `datetime.datetime`, `datetime.date`, and
321
+ `datetime.time` instances to `default`.
319
322
 
320
323
  ```python
321
324
  >>> import ormsgpack, datetime
@@ -336,11 +339,10 @@ TypeError: Type is not msgpack serializable: datetime.datetime
336
339
  b'\x81\xaacreated_at\xbdThu, 01 Jan 1970 00:00:00 GMT'
337
340
  ```
338
341
 
339
- This does not affect datetimes in `dict` keys if using OPT_NON_STR_KEYS.
340
-
341
- ##### OPT_PASSTHROUGH_SUBCLASS
342
+ ##### `OPT_PASSTHROUGH_SUBCLASS`
342
343
 
343
- Passthrough subclasses of builtin types to `default`.
344
+ Enable passthrough of subclasses of `str`, `int`, `dict` and `list` to
345
+ `default`.
344
346
 
345
347
  ```python
346
348
  >>> import ormsgpack
@@ -360,12 +362,9 @@ TypeError: Type is not msgpack serializable: Secret
360
362
  b'\xa6******'
361
363
  ```
362
364
 
363
- This does not affect serializing subclasses as `dict` keys if using
364
- OPT_NON_STR_KEYS.
365
-
366
- ##### OPT_PASSTHROUGH_TUPLE
365
+ ##### `OPT_PASSTHROUGH_TUPLE`
367
366
 
368
- Passthrough tuples to `default`.
367
+ Enable passthrough of `tuple` instances to `default`.
369
368
 
370
369
  ```python
371
370
  >>> import ormsgpack
@@ -385,15 +384,19 @@ b'\x82\xa4type\xa5tuple\xa5value\x93\xcd#\xe9\xa4test*'
385
384
  {'type': 'tuple', 'value': [9193, 'test', 42]}
386
385
  ```
387
386
 
388
- ##### OPT_SERIALIZE_NUMPY
387
+ ##### `OPT_PASSTHROUGH_UUID`
388
+
389
+ Enable passthrough of `uuid.UUID` instances to `default`.
390
+
391
+ ##### `OPT_SERIALIZE_NUMPY`
389
392
 
390
393
  Serialize `numpy.ndarray` instances. For more, see
391
394
  [numpy](#numpy).
392
395
 
393
- ##### OPT_SERIALIZE_PYDANTIC
396
+ ##### `OPT_SERIALIZE_PYDANTIC`
394
397
  Serialize `pydantic.BaseModel` instances.
395
398
 
396
- ##### OPT_SORT_KEYS
399
+ ##### `OPT_SORT_KEYS`
397
400
 
398
401
  Serialize `dict` keys and pydantic model fields in sorted order. The default
399
402
  is to serialize in an unspecified order.
@@ -419,7 +422,7 @@ b'\x83\xa1A\x03\xa1a\x01\xa2\xc3\xa4\x02'
419
422
 
420
423
  `dataclass` also serialize as maps but this has no effect on them.
421
424
 
422
- ##### OPT_UTC_Z
425
+ ##### `OPT_UTC_Z`
423
426
 
424
427
  Serialize a UTC timezone on `datetime.datetime` and `numpy.datetime64` instances
425
428
  as `Z` instead of `+00:00`.
@@ -588,9 +591,6 @@ b'\xaa1900-01-02'
588
591
 
589
592
  Errors with `tzinfo` result in `MsgpackEncodeError` being raised.
590
593
 
591
- To disable serialization of `datetime` objects specify the option
592
- `ormsgpack.OPT_PASSTHROUGH_DATETIME`.
593
-
594
594
  To use "Z" suffix instead of "+00:00" to indicate UTC ("Zulu") time, use the option
595
595
  `ormsgpack.OPT_UTC_Z`.
596
596
 
@@ -21,6 +21,24 @@ classifiers = [
21
21
  "Programming Language :: Rust",
22
22
  "Typing :: Typed",
23
23
  ]
24
+ dynamic = ["version"]
25
+
26
+ [dependency-groups]
27
+ dev = [
28
+ "msgpack",
29
+ "mypy",
30
+ "numpy; platform_machine != 'armv7l'",
31
+ "pendulum; platform_machine != 'armv7l' and python_version < '3.13'",
32
+ "pydantic",
33
+ "pytest",
34
+ "pytest-benchmark",
35
+ "python-dateutil",
36
+ "pytz",
37
+ "ruff",
38
+ "types-python-dateutil",
39
+ "types-pytz",
40
+ "tzdata",
41
+ ]
24
42
 
25
43
  [build-system]
26
44
  build-backend = "maturin"
@@ -28,7 +46,6 @@ requires = ["maturin>=1.0,<2.0"]
28
46
 
29
47
  [tool.maturin]
30
48
  python-source = "python"
31
- strip = true
32
49
 
33
50
  [tool.mypy]
34
51
  exclude = "benchmarks"
@@ -9,6 +9,7 @@ from .ormsgpack import (
9
9
  OPT_PASSTHROUGH_DATETIME,
10
10
  OPT_PASSTHROUGH_SUBCLASS,
11
11
  OPT_PASSTHROUGH_TUPLE,
12
+ OPT_PASSTHROUGH_UUID,
12
13
  OPT_SERIALIZE_NUMPY,
13
14
  OPT_SERIALIZE_PYDANTIC,
14
15
  OPT_SORT_KEYS,
@@ -36,6 +37,7 @@ __all__ = (
36
37
  "OPT_PASSTHROUGH_DATETIME",
37
38
  "OPT_PASSTHROUGH_SUBCLASS",
38
39
  "OPT_PASSTHROUGH_TUPLE",
40
+ "OPT_PASSTHROUGH_UUID",
39
41
  "OPT_SERIALIZE_NUMPY",
40
42
  "OPT_SERIALIZE_PYDANTIC",
41
43
  "OPT_SORT_KEYS",
@@ -26,6 +26,7 @@ OPT_PASSTHROUGH_DATACLASS: int
26
26
  OPT_PASSTHROUGH_DATETIME: int
27
27
  OPT_PASSTHROUGH_SUBCLASS: int
28
28
  OPT_PASSTHROUGH_TUPLE: int
29
+ OPT_PASSTHROUGH_UUID: int
29
30
  OPT_SERIALIZE_NUMPY: int
30
31
  OPT_SERIALIZE_PYDANTIC: int
31
32
  OPT_NON_STR_KEYS: int