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

Add the jiter package #1327

Draft
wants to merge 7 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ name: CI
on:
push:
branches: [master]
workflow_dispatch:

concurrency:
group: ${{ github.ref }}
Expand Down
1 change: 1 addition & 0 deletions product/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8

1 change: 0 additions & 1 deletion server/pypi/build-wheel.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ def main(self):
if name == "python":
self.meta["requirements"]["host"].remove(name)
self.needs_python = True

self.unpack_and_build()

except CommandError as e:
Expand Down
10 changes: 10 additions & 0 deletions server/pypi/packages/jiter/meta.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package:
name: jiter
version: "0.8.0"

about:
license_file: crates/jiter/LICENSE

requirements:
build:
- rust
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
--- src-original/crates/jiter/src/py_string_cache.rs
+++ src/crates/jiter/src/py_string_cache.rs
@@ -200,27 +200,8 @@

pub fn pystring_fast_new<'py>(py: Python<'py>, s: &str, ascii_only: bool) -> Bound<'py, PyString> {
if ascii_only {
- unsafe { pystring_ascii_new(py, s) }
+ PyString::new(py, s)
} else {
PyString::new(py, s)
}
}
-
-/// 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(not(PyPy), not(GraalPy)))]
-unsafe fn pystring_ascii_new<'py>(py: Python<'py>, s: &str) -> Bound<'py, PyString> {
- let ptr = pyo3::ffi::PyUnicode_New(s.len() as isize, 127);
- // see https://github.com/pydantic/jiter/pull/72#discussion_r1545485907
- debug_assert_eq!(pyo3::ffi::PyUnicode_KIND(ptr), pyo3::ffi::PyUnicode_1BYTE_KIND);
- let data_ptr = pyo3::ffi::PyUnicode_DATA(ptr).cast();
- core::ptr::copy_nonoverlapping(s.as_ptr(), data_ptr, s.len());
- core::ptr::write(data_ptr.add(s.len()), 0);
- Bound::from_owned_ptr(py, ptr).downcast_into_unchecked()
-}
-
-// ffi::PyUnicode_DATA seems to be broken for pypy, hence this, marked as unsafe to avoid warnings
-#[cfg(any(PyPy, GraalPy))]
-unsafe fn pystring_ascii_new<'py>(py: Python<'py>, s: &str) -> Bound<'py, PyString> {
- PyString::new_bound(py, s)
-}
11 changes: 11 additions & 0 deletions server/pypi/packages/jiter/patches/pyo3_no_interpreter.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
--- src-original/crates/jiter-python/Cargo.toml
+++ src/crates/jiter-python/Cargo.toml
@@ -10,7 +10,7 @@
repository = {workspace = true}

[dependencies]
-pyo3 = { workspace = true, features = ["num-bigint"] }
+pyo3 = { workspace = true, features = ["num-bigint","abi3-py311"] }
jiter = { path = "../jiter", features = ["python", "num-bigint"] }

[features]
Loading