ormsgpack 1.10.0__tar.gz → 1.11.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.
- {ormsgpack-1.10.0 → ormsgpack-1.11.0}/CHANGELOG.md +8 -0
- {ormsgpack-1.10.0 → ormsgpack-1.11.0}/Cargo.lock +30 -22
- {ormsgpack-1.10.0 → ormsgpack-1.11.0}/Cargo.toml +14 -19
- ormsgpack-1.11.0/PKG-INFO +27 -0
- {ormsgpack-1.10.0 → ormsgpack-1.11.0}/README.md +1 -1
- {ormsgpack-1.10.0 → ormsgpack-1.11.0}/pyproject.toml +13 -1
- {ormsgpack-1.10.0 → ormsgpack-1.11.0}/src/deserialize/cache.rs +25 -12
- {ormsgpack-1.10.0 → ormsgpack-1.11.0}/src/deserialize/deserializer.rs +98 -71
- {ormsgpack-1.10.0 → ormsgpack-1.11.0}/src/deserialize/mod.rs +0 -1
- {ormsgpack-1.10.0 → ormsgpack-1.11.0}/src/ext.rs +6 -6
- {ormsgpack-1.10.0 → ormsgpack-1.11.0}/src/ffi/base/mod.rs +3 -3
- {ormsgpack-1.10.0 → ormsgpack-1.11.0}/src/ffi/base/unicode.rs +1 -1
- {ormsgpack-1.10.0 → ormsgpack-1.11.0}/src/ffi/cpython/int.rs +2 -2
- {ormsgpack-1.10.0 → ormsgpack-1.11.0}/src/ffi/cpython/mod.rs +4 -1
- {ormsgpack-1.10.0 → ormsgpack-1.11.0}/src/ffi/cpython/unicode.rs +63 -23
- {ormsgpack-1.10.0 → ormsgpack-1.11.0}/src/ffi/mod.rs +9 -7
- {ormsgpack-1.10.0 → ormsgpack-1.11.0}/src/ffi/unicode.rs +5 -2
- {ormsgpack-1.10.0 → ormsgpack-1.11.0}/src/lib.rs +60 -36
- {ormsgpack-1.10.0 → ormsgpack-1.11.0}/src/serialize/dataclass.rs +26 -18
- {ormsgpack-1.10.0 → ormsgpack-1.11.0}/src/serialize/datetime.rs +31 -24
- {ormsgpack-1.10.0 → ormsgpack-1.11.0}/src/serialize/default.rs +18 -10
- {ormsgpack-1.10.0 → ormsgpack-1.11.0}/src/serialize/dict.rs +33 -121
- {ormsgpack-1.10.0 → ormsgpack-1.11.0}/src/serialize/ext.rs +3 -3
- {ormsgpack-1.10.0 → ormsgpack-1.11.0}/src/serialize/list.rs +7 -2
- {ormsgpack-1.10.0 → ormsgpack-1.11.0}/src/serialize/numpy.rs +84 -62
- {ormsgpack-1.10.0 → ormsgpack-1.11.0}/src/serialize/pydantic.rs +14 -7
- {ormsgpack-1.10.0 → ormsgpack-1.11.0}/src/serialize/serializer.rs +118 -88
- {ormsgpack-1.10.0 → ormsgpack-1.11.0}/src/serialize/str.rs +2 -2
- {ormsgpack-1.10.0 → ormsgpack-1.11.0}/src/serialize/tuple.rs +6 -1
- {ormsgpack-1.10.0 → ormsgpack-1.11.0}/src/serialize/uuid.rs +11 -7
- {ormsgpack-1.10.0 → ormsgpack-1.11.0}/src/serialize/writer.rs +4 -8
- ormsgpack-1.11.0/src/state.rs +141 -0
- ormsgpack-1.11.0/src/util.rs +41 -0
- ormsgpack-1.10.0/PKG-INFO +0 -964
- ormsgpack-1.10.0/src/typeref.rs +0 -198
- ormsgpack-1.10.0/src/util.rs +0 -81
- {ormsgpack-1.10.0 → ormsgpack-1.11.0}/LICENSE-APACHE +0 -0
- {ormsgpack-1.10.0 → ormsgpack-1.11.0}/LICENSE-MIT +0 -0
- {ormsgpack-1.10.0 → ormsgpack-1.11.0}/build.rs +0 -0
- {ormsgpack-1.10.0 → ormsgpack-1.11.0}/python/ormsgpack/__init__.py +0 -0
- {ormsgpack-1.10.0 → ormsgpack-1.11.0}/python/ormsgpack/__init__.pyi +0 -0
- {ormsgpack-1.10.0 → ormsgpack-1.11.0}/python/ormsgpack/_pyinstaller/__init__.py +0 -0
- {ormsgpack-1.10.0 → ormsgpack-1.11.0}/python/ormsgpack/_pyinstaller/hook-ormsgpack.py +0 -0
- {ormsgpack-1.10.0 → ormsgpack-1.11.0}/python/ormsgpack/py.typed +0 -0
- {ormsgpack-1.10.0 → ormsgpack-1.11.0}/src/deserialize/error.rs +0 -0
- {ormsgpack-1.10.0 → ormsgpack-1.11.0}/src/exc.rs +0 -0
- {ormsgpack-1.10.0 → ormsgpack-1.11.0}/src/ffi/base/int.rs +0 -0
- {ormsgpack-1.10.0 → ormsgpack-1.11.0}/src/ffi/int.rs +0 -0
- {ormsgpack-1.10.0 → ormsgpack-1.11.0}/src/msgpack/array.rs +0 -0
- {ormsgpack-1.10.0 → ormsgpack-1.11.0}/src/msgpack/bin.rs +0 -0
- {ormsgpack-1.10.0 → ormsgpack-1.11.0}/src/msgpack/bool.rs +0 -0
- {ormsgpack-1.10.0 → ormsgpack-1.11.0}/src/msgpack/ext.rs +0 -0
- {ormsgpack-1.10.0 → ormsgpack-1.11.0}/src/msgpack/float.rs +0 -0
- {ormsgpack-1.10.0 → ormsgpack-1.11.0}/src/msgpack/int.rs +0 -0
- {ormsgpack-1.10.0 → ormsgpack-1.11.0}/src/msgpack/map.rs +0 -0
- {ormsgpack-1.10.0 → ormsgpack-1.11.0}/src/msgpack/marker.rs +0 -0
- {ormsgpack-1.10.0 → ormsgpack-1.11.0}/src/msgpack/mod.rs +0 -0
- {ormsgpack-1.10.0 → ormsgpack-1.11.0}/src/msgpack/nil.rs +0 -0
- {ormsgpack-1.10.0 → ormsgpack-1.11.0}/src/msgpack/str.rs +0 -0
- {ormsgpack-1.10.0 → ormsgpack-1.11.0}/src/opt.rs +0 -0
- {ormsgpack-1.10.0 → ormsgpack-1.11.0}/src/serialize/bytearray.rs +0 -0
- {ormsgpack-1.10.0 → ormsgpack-1.11.0}/src/serialize/bytes.rs +0 -0
- {ormsgpack-1.10.0 → ormsgpack-1.11.0}/src/serialize/datetimelike.rs +0 -0
- {ormsgpack-1.10.0 → ormsgpack-1.11.0}/src/serialize/memoryview.rs +0 -0
- {ormsgpack-1.10.0 → ormsgpack-1.11.0}/src/serialize/mod.rs +0 -0
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.11.0 08/10/2025
|
|
4
|
+
|
|
5
|
+
### Changed
|
|
6
|
+
|
|
7
|
+
- Add support for Python 3.14
|
|
8
|
+
- Add support for free-threading and subinterpreters
|
|
9
|
+
- Add Windows arm64 wheels by [JexinSam](https://github.com/JexinSam) in [#412](/../../pull/412)
|
|
10
|
+
|
|
3
11
|
## 1.10.0 24/05/2025
|
|
4
12
|
|
|
5
13
|
### Changed
|
|
@@ -22,9 +22,9 @@ checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26"
|
|
|
22
22
|
|
|
23
23
|
[[package]]
|
|
24
24
|
name = "bytecount"
|
|
25
|
-
version = "0.6.
|
|
25
|
+
version = "0.6.9"
|
|
26
26
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
27
|
-
checksum = "
|
|
27
|
+
checksum = "175812e0be2bccb6abe50bb8d566126198344f707e304f45c648fd8f2cc0365e"
|
|
28
28
|
|
|
29
29
|
[[package]]
|
|
30
30
|
name = "byteorder"
|
|
@@ -40,9 +40,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
|
|
40
40
|
|
|
41
41
|
[[package]]
|
|
42
42
|
name = "chrono"
|
|
43
|
-
version = "0.4.
|
|
43
|
+
version = "0.4.42"
|
|
44
44
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
45
|
-
checksum = "
|
|
45
|
+
checksum = "145052bdd345b87320e369255277e3fb5152762ad123a901ef5c262dd38fe8d2"
|
|
46
46
|
dependencies = [
|
|
47
47
|
"num-traits",
|
|
48
48
|
]
|
|
@@ -101,7 +101,7 @@ checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d"
|
|
|
101
101
|
|
|
102
102
|
[[package]]
|
|
103
103
|
name = "ormsgpack"
|
|
104
|
-
version = "1.
|
|
104
|
+
version = "1.11.0"
|
|
105
105
|
dependencies = [
|
|
106
106
|
"ahash",
|
|
107
107
|
"bytecount",
|
|
@@ -109,7 +109,6 @@ dependencies = [
|
|
|
109
109
|
"chrono",
|
|
110
110
|
"half",
|
|
111
111
|
"itoa",
|
|
112
|
-
"once_cell",
|
|
113
112
|
"pyo3",
|
|
114
113
|
"pyo3-build-config",
|
|
115
114
|
"serde",
|
|
@@ -135,9 +134,9 @@ dependencies = [
|
|
|
135
134
|
|
|
136
135
|
[[package]]
|
|
137
136
|
name = "pyo3"
|
|
138
|
-
version = "0.
|
|
137
|
+
version = "0.26.0"
|
|
139
138
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
140
|
-
checksum = "
|
|
139
|
+
checksum = "7ba0117f4212101ee6544044dae45abe1083d30ce7b29c4b5cbdfa2354e07383"
|
|
141
140
|
dependencies = [
|
|
142
141
|
"libc",
|
|
143
142
|
"memoffset",
|
|
@@ -149,19 +148,18 @@ dependencies = [
|
|
|
149
148
|
|
|
150
149
|
[[package]]
|
|
151
150
|
name = "pyo3-build-config"
|
|
152
|
-
version = "0.
|
|
151
|
+
version = "0.26.0"
|
|
153
152
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
154
|
-
checksum = "
|
|
153
|
+
checksum = "4fc6ddaf24947d12a9aa31ac65431fb1b851b8f4365426e182901eabfb87df5f"
|
|
155
154
|
dependencies = [
|
|
156
|
-
"once_cell",
|
|
157
155
|
"target-lexicon",
|
|
158
156
|
]
|
|
159
157
|
|
|
160
158
|
[[package]]
|
|
161
159
|
name = "pyo3-ffi"
|
|
162
|
-
version = "0.
|
|
160
|
+
version = "0.26.0"
|
|
163
161
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
164
|
-
checksum = "
|
|
162
|
+
checksum = "025474d3928738efb38ac36d4744a74a400c901c7596199e20e45d98eb194105"
|
|
165
163
|
dependencies = [
|
|
166
164
|
"libc",
|
|
167
165
|
"pyo3-build-config",
|
|
@@ -178,27 +176,37 @@ dependencies = [
|
|
|
178
176
|
|
|
179
177
|
[[package]]
|
|
180
178
|
name = "serde"
|
|
181
|
-
version = "1.0.
|
|
179
|
+
version = "1.0.228"
|
|
182
180
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
183
|
-
checksum = "
|
|
181
|
+
checksum = "9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9e"
|
|
184
182
|
dependencies = [
|
|
185
|
-
"
|
|
183
|
+
"serde_core",
|
|
186
184
|
]
|
|
187
185
|
|
|
188
186
|
[[package]]
|
|
189
187
|
name = "serde_bytes"
|
|
190
|
-
version = "0.11.
|
|
188
|
+
version = "0.11.19"
|
|
191
189
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
192
|
-
checksum = "
|
|
190
|
+
checksum = "a5d440709e79d88e51ac01c4b72fc6cb7314017bb7da9eeff678aa94c10e3ea8"
|
|
193
191
|
dependencies = [
|
|
194
192
|
"serde",
|
|
193
|
+
"serde_core",
|
|
194
|
+
]
|
|
195
|
+
|
|
196
|
+
[[package]]
|
|
197
|
+
name = "serde_core"
|
|
198
|
+
version = "1.0.228"
|
|
199
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
200
|
+
checksum = "41d385c7d4ca58e59fc732af25c3983b67ac852c1a25000afe1175de458b67ad"
|
|
201
|
+
dependencies = [
|
|
202
|
+
"serde_derive",
|
|
195
203
|
]
|
|
196
204
|
|
|
197
205
|
[[package]]
|
|
198
206
|
name = "serde_derive"
|
|
199
|
-
version = "1.0.
|
|
207
|
+
version = "1.0.228"
|
|
200
208
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
201
|
-
checksum = "
|
|
209
|
+
checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79"
|
|
202
210
|
dependencies = [
|
|
203
211
|
"proc-macro2",
|
|
204
212
|
"quote",
|
|
@@ -213,9 +221,9 @@ checksum = "e3a9fe34e3e7a50316060351f37187a3f546bce95496156754b601a5fa71b76e"
|
|
|
213
221
|
|
|
214
222
|
[[package]]
|
|
215
223
|
name = "smallvec"
|
|
216
|
-
version = "1.15.
|
|
224
|
+
version = "1.15.1"
|
|
217
225
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
218
|
-
checksum = "
|
|
226
|
+
checksum = "67b1b7a3b5fe4f1376887184045fcf45c69e92af734b7aaddc05fb777b6fbd03"
|
|
219
227
|
|
|
220
228
|
[[package]]
|
|
221
229
|
name = "syn"
|
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
[package]
|
|
2
2
|
name = "ormsgpack"
|
|
3
|
-
version = "1.
|
|
4
|
-
authors = [
|
|
5
|
-
"Aviram Hassan <aviramyhassan@gmail.com>",
|
|
6
|
-
"Emanuele Giaquinta <emanuele.giaquinta@gmail.com>",
|
|
7
|
-
]
|
|
3
|
+
version = "1.11.0"
|
|
8
4
|
description = "Fast, correct Python msgpack library supporting dataclasses, datetimes, and numpy"
|
|
9
5
|
edition = "2021"
|
|
10
6
|
rust-version = "1.81"
|
|
@@ -14,14 +10,14 @@ homepage = "https://github.com/aviramha/ormsgpack"
|
|
|
14
10
|
readme = "README.md"
|
|
15
11
|
keywords = ["fast", "msgpack", "dataclass", "dataclasses", "datetime"]
|
|
16
12
|
include = [
|
|
17
|
-
"build.rs",
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
"LICENSE-
|
|
21
|
-
"
|
|
22
|
-
"
|
|
23
|
-
"README.md",
|
|
24
|
-
"src
|
|
13
|
+
"/build.rs",
|
|
14
|
+
"/CHANGELOG.md",
|
|
15
|
+
"/LICENSE-APACHE",
|
|
16
|
+
"/LICENSE-MIT",
|
|
17
|
+
"/pyproject.toml",
|
|
18
|
+
"/python",
|
|
19
|
+
"/README.md",
|
|
20
|
+
"/src",
|
|
25
21
|
]
|
|
26
22
|
|
|
27
23
|
[lib]
|
|
@@ -38,20 +34,19 @@ unstable-simd = [
|
|
|
38
34
|
|
|
39
35
|
[dependencies]
|
|
40
36
|
ahash = { version = "0.8", default-features = false }
|
|
41
|
-
bytecount = { version = "^0.6.
|
|
37
|
+
bytecount = { version = "^0.6.9", default-features = false, features = ["runtime-dispatch-simd"] }
|
|
42
38
|
byteorder = { version = "1.5.0", default-features = false, features = ["std"] }
|
|
43
|
-
chrono = { version = "0.4.
|
|
39
|
+
chrono = { version = "0.4.42", default-features = false }
|
|
44
40
|
half = { version = "2.6.0", default-features = false }
|
|
45
41
|
itoa = { version = "1", default-features = false }
|
|
46
|
-
|
|
47
|
-
pyo3 = { version = "^0.25.0", default-features = false, features = ["extension-module"] }
|
|
42
|
+
pyo3 = { version = "^0.26.0", default-features = false, features = ["extension-module"] }
|
|
48
43
|
serde = { version = "1", default-features = false }
|
|
49
|
-
serde_bytes = { version = "0.11.
|
|
44
|
+
serde_bytes = { version = "0.11.19", default-features = false, features = ["std"] }
|
|
50
45
|
simdutf8 = { version = "0.1.5", default-features = false, features = ["std"] }
|
|
51
46
|
smallvec = { version = "^1.15", default-features = false, features = ["union", "write"] }
|
|
52
47
|
|
|
53
48
|
[build-dependencies]
|
|
54
|
-
pyo3-build-config = { version = "^0.
|
|
49
|
+
pyo3-build-config = { version = "^0.26.0" }
|
|
55
50
|
|
|
56
51
|
[profile.release]
|
|
57
52
|
codegen-units = 1
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: ormsgpack
|
|
3
|
+
Version: 1.11.0
|
|
4
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
5
|
+
Classifier: Intended Audience :: Developers
|
|
6
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
7
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
8
|
+
Classifier: Operating System :: MacOS
|
|
9
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
10
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
18
|
+
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
19
|
+
Classifier: Programming Language :: Python :: Implementation :: PyPy
|
|
20
|
+
Classifier: Programming Language :: Python
|
|
21
|
+
Classifier: Programming Language :: Rust
|
|
22
|
+
Classifier: Typing :: Typed
|
|
23
|
+
License-File: LICENSE-APACHE
|
|
24
|
+
License-File: LICENSE-MIT
|
|
25
|
+
Home-Page: https://github.com/aviramha/ormsgpack
|
|
26
|
+
Author-email: Aviram Hassan <aviramyhassan@gmail.com>, Emanuele Giaquinta <emanuele.giaquinta@gmail.com>
|
|
27
|
+
Requires-Python: >=3.9
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "ormsgpack"
|
|
3
|
-
repository = "https://github.com/aviramha/ormsgpack"
|
|
4
3
|
requires-python = ">=3.9"
|
|
5
4
|
classifiers = [
|
|
6
5
|
"Development Status :: 5 - Production/Stable",
|
|
@@ -16,6 +15,7 @@ classifiers = [
|
|
|
16
15
|
"Programming Language :: Python :: 3.11",
|
|
17
16
|
"Programming Language :: Python :: 3.12",
|
|
18
17
|
"Programming Language :: Python :: 3.13",
|
|
18
|
+
"Programming Language :: Python :: 3.14",
|
|
19
19
|
"Programming Language :: Python :: Implementation :: CPython",
|
|
20
20
|
"Programming Language :: Python :: Implementation :: PyPy",
|
|
21
21
|
"Programming Language :: Python",
|
|
@@ -23,6 +23,10 @@ classifiers = [
|
|
|
23
23
|
"Typing :: Typed",
|
|
24
24
|
]
|
|
25
25
|
dynamic = ["version"]
|
|
26
|
+
authors = [
|
|
27
|
+
{name = "Aviram Hassan", email = "aviramyhassan@gmail.com"},
|
|
28
|
+
{name = "Emanuele Giaquinta", email = "emanuele.giaquinta@gmail.com"},
|
|
29
|
+
]
|
|
26
30
|
|
|
27
31
|
[dependency-groups]
|
|
28
32
|
dev = [
|
|
@@ -77,5 +81,13 @@ ignore = [
|
|
|
77
81
|
[tool.ruff.lint.isort]
|
|
78
82
|
known-first-party = ["ormsgpack"]
|
|
79
83
|
|
|
84
|
+
[tool.uv]
|
|
85
|
+
cache-keys = [
|
|
86
|
+
{ file = "**/*.rs" },
|
|
87
|
+
{ file = "Cargo.lock" },
|
|
88
|
+
{ file = "Cargo.toml" },
|
|
89
|
+
{ file = "pyproject.toml" },
|
|
90
|
+
]
|
|
91
|
+
|
|
80
92
|
[project.entry-points.pyinstaller40]
|
|
81
93
|
hook-dirs = "ormsgpack._pyinstaller:get_hook_dirs"
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
// SPDX-License-Identifier: (Apache-2.0 OR MIT)
|
|
2
2
|
|
|
3
3
|
use crate::ffi::*;
|
|
4
|
-
use
|
|
5
|
-
use once_cell::unsync::OnceCell;
|
|
4
|
+
use ahash::RandomState;
|
|
6
5
|
use simdutf8::basic::{from_utf8, Utf8Error};
|
|
7
6
|
use std::hash::BuildHasher;
|
|
8
7
|
use std::hash::Hasher;
|
|
9
8
|
use std::ptr::NonNull;
|
|
9
|
+
#[cfg(Py_GIL_DISABLED)]
|
|
10
|
+
use std::sync::Mutex;
|
|
10
11
|
|
|
11
12
|
#[repr(transparent)]
|
|
12
13
|
struct CachedKey {
|
|
@@ -22,19 +23,23 @@ impl CachedKey {
|
|
|
22
23
|
}
|
|
23
24
|
|
|
24
25
|
fn get(&mut self) -> *mut pyo3::ffi::PyObject {
|
|
25
|
-
ffi
|
|
26
|
+
unsafe { pyo3::ffi::Py_INCREF(self.ptr) };
|
|
26
27
|
self.ptr
|
|
27
28
|
}
|
|
28
29
|
}
|
|
29
30
|
|
|
30
31
|
impl Drop for CachedKey {
|
|
31
32
|
fn drop(&mut self) {
|
|
32
|
-
ffi
|
|
33
|
+
unsafe { pyo3::ffi::Py_DECREF(self.ptr) };
|
|
33
34
|
}
|
|
34
35
|
}
|
|
35
36
|
|
|
36
37
|
pub struct KeyMap<const C: usize> {
|
|
38
|
+
#[cfg(Py_GIL_DISABLED)]
|
|
39
|
+
entries: Mutex<Vec<Option<CachedKey>>>,
|
|
40
|
+
#[cfg(not(Py_GIL_DISABLED))]
|
|
37
41
|
entries: Vec<Option<CachedKey>>,
|
|
42
|
+
hash_builder: RandomState,
|
|
38
43
|
}
|
|
39
44
|
|
|
40
45
|
impl<const C: usize> KeyMap<C> {
|
|
@@ -43,30 +48,38 @@ impl<const C: usize> KeyMap<C> {
|
|
|
43
48
|
for _ in 0..C {
|
|
44
49
|
entries.push(None);
|
|
45
50
|
}
|
|
46
|
-
KeyMap {
|
|
51
|
+
KeyMap {
|
|
52
|
+
#[cfg(Py_GIL_DISABLED)]
|
|
53
|
+
entries: Mutex::new(entries),
|
|
54
|
+
#[cfg(not(Py_GIL_DISABLED))]
|
|
55
|
+
entries: entries,
|
|
56
|
+
hash_builder: RandomState::new(),
|
|
57
|
+
}
|
|
47
58
|
}
|
|
48
59
|
|
|
49
60
|
pub fn get(&mut self, key: &[u8]) -> Result<NonNull<pyo3::ffi::PyObject>, Utf8Error> {
|
|
50
|
-
let mut hasher = unsafe { HASH_BUILDER.get().unwrap().build_hasher() };
|
|
51
61
|
let hash = {
|
|
62
|
+
let mut hasher = self.hash_builder.build_hasher();
|
|
52
63
|
hasher.write(key);
|
|
53
64
|
hasher.finish()
|
|
54
65
|
} as usize;
|
|
55
66
|
let index = hash % C;
|
|
56
|
-
|
|
67
|
+
#[cfg(Py_GIL_DISABLED)]
|
|
68
|
+
let mut entries = self.entries.lock().unwrap();
|
|
69
|
+
#[cfg(not(Py_GIL_DISABLED))]
|
|
70
|
+
let entries = &mut self.entries;
|
|
71
|
+
let entry = match &mut entries[index] {
|
|
57
72
|
Some(v) if unicode_to_str(v.ptr).unwrap().as_bytes() == key => v,
|
|
58
73
|
_ => {
|
|
59
74
|
let pykey = unicode_from_str(from_utf8(key)?);
|
|
60
75
|
hash_str(pykey);
|
|
61
|
-
|
|
62
|
-
match &mut
|
|
76
|
+
entries[index] = Some(CachedKey::new(pykey));
|
|
77
|
+
match &mut entries[index] {
|
|
63
78
|
Some(v) => v,
|
|
64
79
|
_ => unreachable!(),
|
|
65
80
|
}
|
|
66
81
|
}
|
|
67
82
|
};
|
|
68
|
-
Ok(
|
|
83
|
+
unsafe { Ok(NonNull::new_unchecked(entry.get())) }
|
|
69
84
|
}
|
|
70
85
|
}
|
|
71
|
-
|
|
72
|
-
pub static mut KEY_MAP: OnceCell<KeyMap<512>> = OnceCell::new();
|