From 6f0c30605fbe9421dc9594e53063c71e9a32d35a Mon Sep 17 00:00:00 2001 From: jeffwang0516 Date: Tue, 2 Aug 2022 01:12:25 +0800 Subject: [PATCH 1/2] Add itertools.starmap.__reduce__ --- 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 3366bc21ec6..63b37b6198a 100644 --- a/vm/src/stdlib/itertools.rs +++ b/vm/src/stdlib/itertools.rs @@ -404,7 +404,15 @@ mod decl { } #[pyimpl(with(IterNext, Constructor), flags(BASETYPE))] - impl PyItertoolsStarmap {} + impl PyItertoolsStarmap { + #[pymethod(magic)] + fn reduce(zelf: PyRef) -> (PyTypeRef, (PyObjectRef, PyIter)) { + ( + zelf.class().clone(), + (zelf.function.clone(), zelf.iterable.clone()), + ) + } + } impl IterNextIterable for PyItertoolsStarmap {} impl IterNext for PyItertoolsStarmap { fn next(zelf: &Py, vm: &VirtualMachine) -> PyResult { From e5437e451495ffc3cad4be7a5e6800da8d114d69 Mon Sep 17 00:00:00 2001 From: jeffwang0516 Date: Tue, 2 Aug 2022 01:15:09 +0800 Subject: [PATCH 2/2] remove expected failures for related unittest --- Lib/test/test_itertools.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/Lib/test/test_itertools.py b/Lib/test/test_itertools.py index a064846d3fa..3530fc6c535 100644 --- a/Lib/test/test_itertools.py +++ b/Lib/test/test_itertools.py @@ -1226,8 +1226,6 @@ def test_map(self): c = map(tupleize, 'abc', count()) self.pickletest(proto, c) - # TODO: RUSTPYTHON - @unittest.expectedFailure def test_starmap(self): self.assertEqual(list(starmap(operator.pow, zip(range(3), range(1,7)))), [0**1, 1**2, 2**3])