From c7d22cbf3130d054ded672bcd59a0adcc4ee762d Mon Sep 17 00:00:00 2001 From: David Hewitt Date: Sat, 23 Dec 2023 18:24:05 +0000 Subject: [PATCH] fix compile errors --- pyo3-benches/benches/bench_comparisons.rs | 8 ++++---- pyo3-benches/benches/bench_dict.rs | 4 ++-- pyo3-benches/benches/bench_extract.rs | 8 ++++---- pyo3-benches/benches/bench_frompyobject.rs | 2 +- pytests/src/pyfunctions.rs | 6 +++--- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/pyo3-benches/benches/bench_comparisons.rs b/pyo3-benches/benches/bench_comparisons.rs index dd08558b148..7ce87b1506d 100644 --- a/pyo3-benches/benches/bench_comparisons.rs +++ b/pyo3-benches/benches/bench_comparisons.rs @@ -47,11 +47,11 @@ fn bench_ordered_dunder_methods(b: &mut Bencher<'_>) { Python::with_gil(|py| { let obj1 = Py::new(py, OrderedDunderMethods(0)) .unwrap() - .attach_into(py) + .into_bound(py) .into_any(); let obj2 = Py::new(py, OrderedDunderMethods(1)) .unwrap() - .attach_into(py) + .into_bound(py) .into_any(); b.iter(|| obj2.gt(&obj1).unwrap()); @@ -62,11 +62,11 @@ fn bench_ordered_richcmp(b: &mut Bencher<'_>) { Python::with_gil(|py| { let obj1 = Py::new(py, OrderedRichcmp(0)) .unwrap() - .attach_into(py) + .into_bound(py) .into_any(); let obj2 = Py::new(py, OrderedRichcmp(1)) .unwrap() - .attach_into(py) + .into_bound(py) .into_any(); b.iter(|| obj2.gt(&obj1).unwrap()); diff --git a/pyo3-benches/benches/bench_dict.rs b/pyo3-benches/benches/bench_dict.rs index ae11e6140a1..ce092641287 100644 --- a/pyo3-benches/benches/bench_dict.rs +++ b/pyo3-benches/benches/bench_dict.rs @@ -1,6 +1,6 @@ use codspeed_criterion_compat::{criterion_group, criterion_main, Bencher, Criterion}; -use pyo3::types::{IntoPyDict, PyDict}; +use pyo3::types::IntoPyDict; use pyo3::{prelude::*, types::PyMapping}; use std::collections::{BTreeMap, HashMap}; use std::hint::black_box; @@ -12,7 +12,7 @@ fn iter_dict(b: &mut Bencher<'_>) { let dict = &dict.as_borrowed(); let mut sum = 0; b.iter(|| { - for (k, _v) in dict { + for (k, _v) in dict.iter() { let i: u64 = k.extract().unwrap(); sum += i; } diff --git a/pyo3-benches/benches/bench_extract.rs b/pyo3-benches/benches/bench_extract.rs index b8db162cb47..83941eac97c 100644 --- a/pyo3-benches/benches/bench_extract.rs +++ b/pyo3-benches/benches/bench_extract.rs @@ -52,7 +52,7 @@ fn extract_str_downcast_fail(bench: &mut Bencher<'_>) { fn extract_int_extract_success(bench: &mut Bencher<'_>) { Python::with_gil(|py| { let int_obj: PyObject = 123.into_py(py); - let int = int_obj.attach(py); + let int = int_obj.bind(py); bench.iter(|| { let v = black_box(int).extract::().unwrap(); @@ -76,7 +76,7 @@ fn extract_int_extract_fail(bench: &mut Bencher<'_>) { fn extract_int_downcast_success(bench: &mut Bencher<'_>) { Python::with_gil(|py| { let int_obj: PyObject = 123.into_py(py); - let int = int_obj.attach(py); + let int = int_obj.bind(py); bench.iter(|| { let py_int = black_box(int).downcast::().unwrap(); @@ -101,7 +101,7 @@ fn extract_int_downcast_fail(bench: &mut Bencher<'_>) { fn extract_float_extract_success(bench: &mut Bencher<'_>) { Python::with_gil(|py| { let float_obj: PyObject = 23.42.into_py(py); - let float = float_obj.attach(py); + let float = float_obj.bind(py); bench.iter(|| { let v = black_box(float).extract::().unwrap(); @@ -125,7 +125,7 @@ fn extract_float_extract_fail(bench: &mut Bencher<'_>) { fn extract_float_downcast_success(bench: &mut Bencher<'_>) { Python::with_gil(|py| { let float_obj: PyObject = 23.42.into_py(py); - let float = float_obj.attach(py); + let float = float_obj.bind(py); bench.iter(|| { let py_int = black_box(float).downcast::().unwrap(); diff --git a/pyo3-benches/benches/bench_frompyobject.rs b/pyo3-benches/benches/bench_frompyobject.rs index 8114ee5a802..2bba0d0a12a 100644 --- a/pyo3-benches/benches/bench_frompyobject.rs +++ b/pyo3-benches/benches/bench_frompyobject.rs @@ -62,7 +62,7 @@ fn not_a_list_via_extract_enum(b: &mut Bencher<'_>) { Python::with_gil(|py| { let any: &Bound<'_, PyAny> = &PyString::new_bound(py, "foobar"); - b.iter(|| match black_box(any).extract::>() { + b.iter(|| match black_box(&any).extract::>() { Ok(ListOrNotList::List(_list)) => panic!(), Ok(ListOrNotList::NotList(any)) => any, Err(_) => panic!(), diff --git a/pytests/src/pyfunctions.rs b/pytests/src/pyfunctions.rs index 5629441c3a5..09d9468f925 100644 --- a/pytests/src/pyfunctions.rs +++ b/pytests/src/pyfunctions.rs @@ -4,9 +4,9 @@ use pyo3::types::{PyDict, PyTuple}; #[pyfunction(signature = ())] fn none() {} -type Any<'py> = Py2<'py, pyo3::PyAny>; -type Dict<'py> = Py2<'py, PyDict>; -type Tuple<'py> = Py2<'py, PyTuple>; +type Any<'py> = Bound<'py, pyo3::PyAny>; +type Dict<'py> = Bound<'py, PyDict>; +type Tuple<'py> = Bound<'py, PyTuple>; #[pyfunction(signature = (a, b = None, *, c = None))] fn simple<'py>(