From 94029386ae85f31a7ebd29395b28af686d9785b0 Mon Sep 17 00:00:00 2001 From: LucaSforza Date: Sun, 23 Jul 2023 16:52:34 +0200 Subject: [PATCH] added __reduce__ method for itertools.permutations --- vm/src/stdlib/itertools.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/vm/src/stdlib/itertools.rs b/vm/src/stdlib/itertools.rs index 91dbd7489db..526ab61af3d 100644 --- a/vm/src/stdlib/itertools.rs +++ b/vm/src/stdlib/itertools.rs @@ -1670,7 +1670,15 @@ mod decl { } #[pyclass(with(IterNext, Iterable, Constructor))] - impl PyItertoolsPermutations {} + impl PyItertoolsPermutations { + #[pymethod(magic)] + fn reduce(zelf: PyRef, vm: &VirtualMachine) -> PyRef { + 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, vm: &VirtualMachine) -> PyResult {