Skip to content

Commit

Permalink
restore pystring_ascii_new fast path, using new PyO3 instead
Browse files Browse the repository at this point in the history
  • Loading branch information
davidhewitt committed Dec 3, 2024
1 parent 06aa3a5 commit ed8fbbd
Showing 1 changed file with 2 additions and 14 deletions.
16 changes: 2 additions & 14 deletions crates/jiter/src/py_string_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,13 +208,7 @@ pub fn pystring_fast_new<'py>(py: Python<'py>, s: &str, ascii_only: bool) -> Bou

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

// unoptimized version (albeit not that much slower) on other platforms
#[cfg(not(all(
any(
all(target_arch = "x86_64", target_os = "linux"),
all(target_arch = "aarch64", target_os = "macos"),
),
not(any(PyPy, GraalPy)),
)))]
#[cfg(any(PyPy, GraalPy))]
unsafe fn pystring_ascii_new<'py>(py: Python<'py>, s: &str) -> Bound<'py, PyString> {
PyString::new(py, s)
}

0 comments on commit ed8fbbd

Please sign in to comment.