From a9ca295821443efc7dc99fabc8e8f623dbcee723 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 18 Nov 2024 23:30:27 +0000 Subject: [PATCH 1/2] deps: update pyo3 requirement from 0.22.3 to 0.23.1 Updates the requirements on [pyo3](https://github.com/pyo3/pyo3) to permit the latest version. - [Release notes](https://github.com/pyo3/pyo3/releases) - [Changelog](https://github.com/PyO3/pyo3/blob/main/CHANGELOG.md) - [Commits](https://github.com/pyo3/pyo3/compare/v0.22.3...v0.23.1) --- updated-dependencies: - dependency-name: pyo3 dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- sprs-benches/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sprs-benches/Cargo.toml b/sprs-benches/Cargo.toml index bf614021..d4936178 100644 --- a/sprs-benches/Cargo.toml +++ b/sprs-benches/Cargo.toml @@ -10,7 +10,7 @@ edition.workspace = true sprs = { version = "0.11.0", path = "../sprs" } sprs-rand = { version = "0.4.0", path = "../sprs-rand" } plotters = "0.3.4" -pyo3 = { version = "0.22.3", features = ["auto-initialize"] } +pyo3 = { version = "0.23.1", features = ["auto-initialize"] } [build-dependencies] cc = "1.0.52" From 56f153dc62cf2a4ce82190a784abc3984e0e3680 Mon Sep 17 00:00:00 2001 From: Magnus Ulimoen Date: Tue, 19 Nov 2024 22:19:48 +0100 Subject: [PATCH 2/2] Update pyo3 code --- sprs-benches/src/main.rs | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/sprs-benches/src/main.rs b/sprs-benches/src/main.rs index 91864520..8474e3b8 100644 --- a/sprs-benches/src/main.rs +++ b/sprs-benches/src/main.rs @@ -7,7 +7,7 @@ use sprs_rand::rand_csr_std; fn scipy_mat<'a>( scipy_sparse: &Bound<'a, PyModule>, - py: Python, + py: Python<'a>, mat: &sprs::CsMat, ) -> Result, String> { let indptr = mat.indptr().to_proper().to_vec(); @@ -15,7 +15,7 @@ fn scipy_mat<'a>( .call_method( "csr_matrix", ((mat.data().to_vec(), mat.indices().to_vec(), indptr),), - Some(&[("shape", mat.shape())].into_py_dict_bound(py)), + Some(&[("shape", mat.shape())].into_py_dict(py).unwrap()), ) .map_err(|e| { let res = format!("Python error: {e:?}"); @@ -163,12 +163,11 @@ fn bench_densities_with_py( }, ]; - let scipy_sparse = - PyModule::import_bound(py, "scipy.sparse").map_err(|e| { - let res = format!("Python error: {e:?}"); - e.print_and_set_sys_last_vars(py); - res - })?; + let scipy_sparse = PyModule::import(py, "scipy.sparse").map_err(|e| { + let res = format!("Python error: {e:?}"); + e.print_and_set_sys_last_vars(py); + res + })?; for spec in &bench_specs { let shape = spec.shape; @@ -269,12 +268,9 @@ fn bench_densities_with_py( let m2_py = scipy_mat(&scipy_sparse, py, &m2)?; let now = std::time::Instant::now(); let _prod_py = py - .eval_bound( - "m1 * m2", - Some( - &[("m1", m1_py), ("m2", m2_py)] - .into_py_dict_bound(py), - ), + .eval( + c"m1 * m2", + Some(&[("m1", m1_py), ("m2", m2_py)].into_py_dict(py)?), None, ) .map_err(|e| {