mirror of
https://github.com/RustPython/RustPython.git
synced 2026-06-09 22:49:57 +09:00
Merge pull request #3988 from jeffwang0516/starmap-reduce
Add `itertools.starmap.__reduce__`
This commit is contained in:
2
Lib/test/test_itertools.py
vendored
2
Lib/test/test_itertools.py
vendored
@@ -1226,8 +1226,6 @@ class TestBasicOps(unittest.TestCase):
|
||||
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])
|
||||
|
||||
@@ -404,7 +404,15 @@ mod decl {
|
||||
}
|
||||
|
||||
#[pyimpl(with(IterNext, Constructor), flags(BASETYPE))]
|
||||
impl PyItertoolsStarmap {}
|
||||
impl PyItertoolsStarmap {
|
||||
#[pymethod(magic)]
|
||||
fn reduce(zelf: PyRef<Self>) -> (PyTypeRef, (PyObjectRef, PyIter)) {
|
||||
(
|
||||
zelf.class().clone(),
|
||||
(zelf.function.clone(), zelf.iterable.clone()),
|
||||
)
|
||||
}
|
||||
}
|
||||
impl IterNextIterable for PyItertoolsStarmap {}
|
||||
impl IterNext for PyItertoolsStarmap {
|
||||
fn next(zelf: &Py<Self>, vm: &VirtualMachine) -> PyResult<PyIterReturn> {
|
||||
|
||||
Reference in New Issue
Block a user