Skip to content

Commit

Permalink
fix compile errors
Browse files Browse the repository at this point in the history
  • Loading branch information
davidhewitt committed Jan 29, 2024
1 parent 97386b3 commit 3eb1a26
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 14 deletions.
8 changes: 4 additions & 4 deletions pyo3-benches/benches/bench_comparisons.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand All @@ -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());
Expand Down
4 changes: 2 additions & 2 deletions pyo3-benches/benches/bench_dict.rs
Original file line number Diff line number Diff line change
@@ -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};

Expand All @@ -11,7 +11,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;
}
Expand Down
8 changes: 4 additions & 4 deletions pyo3-benches/benches/bench_extract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<i64>().unwrap();
Expand All @@ -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::<PyInt>().unwrap();
Expand All @@ -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::<f64>().unwrap();
Expand All @@ -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::<PyFloat>().unwrap();
Expand Down
2 changes: 1 addition & 1 deletion pyo3-benches/benches/bench_frompyobject.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<ListOrNotList<'_>>() {
b.iter(|| match black_box(&any).extract::<ListOrNotList<'_>>() {
Ok(ListOrNotList::List(_list)) => panic!(),
Ok(ListOrNotList::NotList(any)) => any,
Err(_) => panic!(),
Expand Down
6 changes: 3 additions & 3 deletions pytests/src/pyfunctions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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>(
Expand Down

0 comments on commit 3eb1a26

Please sign in to comment.