Skip to content

Commit

Permalink
Leverage simplified Python protocols
Browse files Browse the repository at this point in the history
  • Loading branch information
djc committed Nov 10, 2021
1 parent b0c7dab commit c302360
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions instant-distance-py/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,9 @@ use std::iter::FromIterator;
use instant_distance::Point;
use pyo3::conversion::IntoPy;
use pyo3::exceptions::{PyTypeError, PyValueError};
use pyo3::proc_macro::{pyclass, pymethods, pymodule, pyproto};
use pyo3::proc_macro::{pyclass, pymethods, pymodule};
use pyo3::types::{PyList, PyModule, PyString};
use pyo3::{
Py, PyAny, PyErr, PyIterProtocol, PyObject, PyObjectProtocol, PyRef, PyRefMut, PyResult, Python,
};
use pyo3::{Py, PyAny, PyErr, PyObject, PyRef, PyRefMut, PyResult, Python};
use serde::{Deserialize, Serialize};
use serde_big_array::big_array;

Expand Down Expand Up @@ -158,10 +156,7 @@ impl Search {
cur: None,
}
}
}

#[pyproto]
impl PyIterProtocol for Search {
fn __iter__(slf: PyRef<Self>) -> PyRef<Self> {
slf
}
Expand Down Expand Up @@ -330,8 +325,8 @@ struct Neighbor {
value: PyObject,
}

#[pyproto]
impl PyObjectProtocol for Neighbor {
#[pymethods]
impl Neighbor {
fn __repr__(&self) -> PyResult<String> {
match Python::with_gil(|py| self.value.is_none(py)) {
false => Ok(format!(
Expand Down

0 comments on commit c302360

Please sign in to comment.