Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[RFC] Add itertools.pairwise() #2351

Copy link
Copy link
@darleybarreto

Description

@darleybarreto
Issue body actions

Summary

To keep up-to-date with CPython's implementation for 3.10, we should add itertools.pairwise().

Detailed Explanation

Looking at vm/src/stdlib/itertools.rs, it seems that we need something like

#[pyattr]
#[pyclass(name = "pairwise")]
#[derive(Debug)]
struct PyItertoolsPairwise {
    ...
}

impl PyValue for PyItertoolsPairwise {
    fn class(_vm: &VirtualMachine) -> &PyTypeRef {
        Self::static_type()
    }
}

#[pyimpl(with(PyIter))]
impl PyItertoolsPairwise {
    #[pyslot]
    fn tp_new(
        cls: PyTypeRef,
        iterable: PyObjectRef,
        vm: &VirtualMachine,
    ) -> PyResult<PyRef<Self>> {
        ...
        PyItertoolsPairwise {
            ...
        }
        .into_ref_with_type(vm, cls)
    }
}

impl PyIter for PyItertoolsPairwise {
    fn next(zelf: &PyRef<Self>, vm: &VirtualMachine) -> PyResult {
        ...
    }
}
Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Labels

    RFCRequest for commentsRequest for comments

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.