added __reduce__ method for itertools.permutations

This commit is contained in:
LucaSforza
2023-07-23 16:52:34 +02:00
committed by Jeong YunWon
parent d5a62848dd
commit 94029386ae

View File

@@ -1670,7 +1670,15 @@ mod decl {
}
#[pyclass(with(IterNext, Iterable, Constructor))]
impl PyItertoolsPermutations {}
impl PyItertoolsPermutations {
#[pymethod(magic)]
fn reduce(zelf: PyRef<Self>, vm: &VirtualMachine) -> PyRef<PyTuple> {
vm.new_tuple((
zelf.class().to_owned(),
vm.new_tuple((zelf.pool.clone(), vm.ctx.new_int(zelf.r.load()))),
))
}
}
impl SelfIter for PyItertoolsPermutations {}
impl IterNext for PyItertoolsPermutations {
fn next(zelf: &Py<Self>, vm: &VirtualMachine) -> PyResult<PyIterReturn> {