Skip to content

MAINT Directly cimport interfaces from std::algorithm #27682

Closed
@jjerphan

Description

@jjerphan

Some Cython implementations use interfaces from the standard library of C++, namely std::algorithm::move and std::algorithm::fill from std::algorithm.

Before Cython 3, those interfaces had to be imported directly using the verbose syntax from Cython:

  • # TODO: change for `libcpp.algorithm.move` once Cython 3 is used
    # Introduction in Cython:
    # https://github.com/cython/cython/blob/05059e2a9b89bf6738a7750b905057e5b1e3fe2e/Cython/Includes/libcpp/algorithm.pxd#L47 #noqa
    cdef extern from "<algorithm>" namespace "std" nogil:
    OutputIt move[InputIt, OutputIt](InputIt first, InputIt last, OutputIt d_first) except + #noqa
  • # TODO: change for `libcpp.algorithm.fill` once Cython 3 is used
    # Introduction in Cython:
    #
    # https://github.com/cython/cython/blob/05059e2a9b89bf6738a7750b905057e5b1e3fe2e/Cython/Includes/libcpp/algorithm.pxd#L50 #noqa
    cdef extern from "<algorithm>" namespace "std" nogil:
    void fill[Iter, T](Iter first, Iter last, const T& value) except + #noqa

Cython 3 introduced the following line natively, for those interfaces. Those interfaces should now be cimported directly. That is one can replace the line shown above respectively with:

from libcpp.algorithm cimport move
from libcpp.algorithm cimport fill

I believe this is a good first Cython issue.

Any reader should feel free to pick it up. It might be possible that there is some context missing.

Please let me know if you need help. 🙂

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions