Skip to content

Commit 281207c

Browse files
committed
restore pystring_ascii_new fast path, using new PyO3 instead
1 parent 06aa3a5 commit 281207c

File tree

2 files changed

+6
-14
lines changed

2 files changed

+6
-14
lines changed

Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,7 @@ debug = true
3131
[workspace.dependencies]
3232
pyo3 = { version = "0.23" }
3333
pyo3-build-config = { version = "0.23" }
34+
35+
[patch.crates-io]
36+
pyo3 = { git = "https://github.com/davidhewitt/pyo3", branch = "config-file-env-var" }
37+
pyo3-build-config = { git = "https://github.com/davidhewitt/pyo3", branch = "config-file-env-var" }

crates/jiter/src/py_string_cache.rs

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -208,13 +208,7 @@ pub fn pystring_fast_new<'py>(py: Python<'py>, s: &str, ascii_only: bool) -> Bou
208208

209209
/// Faster creation of PyString from an ASCII string, inspired by
210210
/// https://github.com/ijl/orjson/blob/3.10.0/src/str/create.rs#L41
211-
#[cfg(all(
212-
any(
213-
all(target_arch = "x86_64", target_os = "linux"),
214-
all(target_arch = "aarch64", target_os = "macos"),
215-
),
216-
not(any(PyPy, GraalPy))
217-
))]
211+
#[cfg(not(any(PyPy, GraalPy)))]
218212
unsafe fn pystring_ascii_new<'py>(py: Python<'py>, s: &str) -> Bound<'py, PyString> {
219213
// disabled on everything except tier-1 platforms because of a crash in the built wheels from CI,
220214
// see https://github.com/pydantic/jiter/pull/175
@@ -229,13 +223,7 @@ unsafe fn pystring_ascii_new<'py>(py: Python<'py>, s: &str) -> Bound<'py, PyStri
229223
}
230224

231225
// unoptimized version (albeit not that much slower) on other platforms
232-
#[cfg(not(all(
233-
any(
234-
all(target_arch = "x86_64", target_os = "linux"),
235-
all(target_arch = "aarch64", target_os = "macos"),
236-
),
237-
not(any(PyPy, GraalPy)),
238-
)))]
226+
#[cfg(any(PyPy, GraalPy))]
239227
unsafe fn pystring_ascii_new<'py>(py: Python<'py>, s: &str) -> Bound<'py, PyString> {
240228
PyString::new(py, s)
241229
}

0 commit comments

Comments
 (0)