implement reduce method to PySlice

Signed-off-by: yyun-d <yeo1998@naver.com>
This commit is contained in:
yyun-d
2021-11-20 18:59:18 +09:00
parent 69491800e1
commit fd3a0f6d86

View File

@@ -194,6 +194,20 @@ impl PySlice {
let (start, stop, step) = self.inner_indices(length, vm)?;
Ok(vm.new_tuple((start, stop, step)))
}
#[allow(clippy::type_complexity)]
#[pymethod(magic)]
fn reduce(
zelf: PyRef<Self>,
) -> PyResult<(
PyTypeRef,
(Option<PyObjectRef>, PyObjectRef, Option<PyObjectRef>),
)> {
Ok((
zelf.clone_class(),
(zelf.start.clone(), zelf.stop.clone(), zelf.step.clone()),
))
}
}
impl Comparable for PySlice {