Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

restore pystring_ascii_new fast path, using PyO3 0.23.3 #180

Merged
merged 1 commit into from
Dec 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
}
Loading