added __reduce__ method for itertools.permutations

This commit is contained in:
LucaSforza authored and Jeong YunWon committed 2023-08-27 02:13:44 +09:00
1 parent d5a62848dd
commit 94029386ae
1 file changed
+9 -1
+9 -1
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> {