Merge pull request #5029 from LucaSforza/main

added __reduce__ method for itertools.permutations
This commit is contained in:
Jeong, YunWon
2023-08-27 03:19:37 +09:00
committed by GitHub

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> {