Skip to content

Commit 8dd4f8e

Browse files
davidhewittIcxolungoldbaum
authoredFeb 19, 2025
support 3.13t free-threaded python (#471)
* support 3.13t free-threaded python * make dynamic borrow-checking threadsafe * fix compiler error in benches target * fix warning on nightly rust about extern usage * remove parking_lot dependency * Add deadlock-avoidance using direct FFI calls * refactor BorrowFlags tests to not hold a lock in the tests * fix clippy * give BorrowFlagsState fields descriptive names * move thread state guard into the crate root * use ThreadStateGuard to avoid deadlocks acquiring the dtype cache --------- Co-authored-by: Icxolu <10486322+Icxolu@users.noreply.github.com> Co-authored-by: Nathan Goldbaum <nathan.goldbaum@gmail.com>
1 parent 2a579ad commit 8dd4f8e

File tree

10 files changed

+198
-144
lines changed

10 files changed

+198
-144
lines changed
 

‎.github/workflows/ci.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ jobs:
3939
"3.11",
4040
"3.12",
4141
"3.13",
42+
"3.13t",
4243
"pypy-3.9",
4344
"pypy-3.10",
4445
]
@@ -108,7 +109,7 @@ jobs:
108109
steps:
109110
- uses: actions/checkout@v4
110111
- name: Set up Python ${{ matrix.python-version }}
111-
uses: actions/setup-python@v5
112+
uses: Quansight-Labs/setup-python@v5
112113
with:
113114
python-version: ${{ matrix.python-version }}
114115
architecture: ${{ matrix.platform.python-architecture }}

‎CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
# Changelog
2+
- v0.24.0
3+
- Support Python 3.13t "free-threaded" Python. ([#471](https://github.com/PyO3/rust-numpy/pull/471)
4+
25
- v0.23.0
36
- Drop support for PyPy 3.7 and 3.8. ([#470](https://github.com/PyO3/rust-numpy/pull/470))
47
- Require `Element: Sync` as part of the free-threading support in PyO3 0.23 ([#469](https://github.com/PyO3/rust-numpy/pull/469))

‎Cargo.toml

+4-1
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,15 @@ num-complex = ">= 0.2, < 0.5"
2222
num-integer = "0.1"
2323
num-traits = "0.2"
2424
ndarray = ">= 0.15, < 0.17"
25-
pyo3 = { version = "0.23.3", default-features = false, features = ["macros"] }
25+
pyo3 = { version = "0.23.4", default-features = false, features = ["macros"] }
2626
rustc-hash = "2.0"
2727

2828
[dev-dependencies]
2929
pyo3 = { version = "0.23.3", default-features = false, features = ["auto-initialize"] }
3030
nalgebra = { version = ">=0.30, <0.34", default-features = false, features = ["std"] }
3131

32+
[build-dependencies]
33+
pyo3-build-config = { version = "0.23.1", features = ["resolve-config"] }
34+
3235
[package.metadata.docs.rs]
3336
all-features = true

‎benches/array.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use test::{black_box, Bencher};
66
use std::ops::Range;
77

88
use numpy::{PyArray1, PyArray2, PyArray3};
9-
use pyo3::{types::PyAnyMethods, Bound, Python};
9+
use pyo3::{types::PyAnyMethods, Bound, IntoPyObjectExt, Python};
1010

1111
#[bench]
1212
fn extract_success(bencher: &mut Bencher) {
@@ -115,7 +115,11 @@ fn from_slice_large(bencher: &mut Bencher) {
115115
}
116116

117117
fn from_object_slice(bencher: &mut Bencher, size: usize) {
118-
let vec = Python::with_gil(|py| (0..size).map(|val| val.to_object(py)).collect::<Vec<_>>());
118+
let vec = Python::with_gil(|py| {
119+
(0..size)
120+
.map(|val| val.into_py_any(py).unwrap())
121+
.collect::<Vec<_>>()
122+
});
119123

120124
Python::with_gil(|py| {
121125
bencher.iter(|| {

‎build.rs

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
fn main() {
2+
pyo3_build_config::use_pyo3_cfgs();
3+
}

0 commit comments

Comments
 (0)
Failed to load comments.