Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mark functions as noexcept to support Cython 3 #6936

Merged
merged 9 commits into from
May 16, 2023

Conversation

matusvalo
Copy link
Contributor

@matusvalo matusvalo commented May 15, 2023

Description

This PR marks functions as noexcept. noexcept keyword was introduced in Cython 3.0 b1 and Cython 0.29.31 to explicitly declare function as not propagating exceptions.This is important because exceptions are propagated by default in Cython3 [1]. Following functions are marked as noexcept in this PR:

  • functions having void return type - function returning void in Cython 3 is by default checking an exception after every call. This can possibly end up as performance degradation when function is also marked as nogil - see [1] for details.
  • inline functions - inline functions should be performance sensitive so I marked them as noexcept to avoid any (even minor) overhead

Note: This PR is not changing anything for Cython 0.29.X (and therefore should be 100% safe) because noexcept
keyword is ignored (since is equal to default error handling behaviour) in Cython 0.29.X.

This PR is bumping Cython version to 0.29.32. For compilation with Cython3, master branch or Cython 3.0 beta 3 (not released in time of creating this PR) should be used.

[1] https://cython.readthedocs.io/en/latest/src/userguide/migrating_to_cy30.html#exception-values-and-noexcept
[2] https://cython.readthedocs.io/en/latest/src/userguide/language_basics.html#error-return-values

Checklist

  • Docstrings for all functions
  • Gallery example in ./doc/examples (new features only)
  • Benchmark in ./benchmarks, if your changes aren't covered by an
    existing benchmark
  • Unit tests
  • Clean style in the spirit of PEP8
  • Descriptive commit messages (see below)

For reviewers

  • Check that the PR title is short, concise, and will make sense 1 year
    later.
  • Check that new functions are imported in corresponding __init__.py.
  • Check that new features, API changes, and deprecations are mentioned in
    doc/release/release_dev.rst.
  • There is a bot to help automate backporting a PR to an older branch. For
    example, to backport to v0.19.x after merging, add the following in a PR
    comment: @meeseeksdev backport to v0.19.x
  • To run benchmarks on a PR, add the run-benchmark label. To rerun, the label
    can be removed and then added again. The benchmark output can be checked in
    the "Actions" tab.

Copy link
Member

@stefanv stefanv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @matusvalo, this is very helpful!

@jarrodmillman jarrodmillman added this to the 0.21 milestone May 16, 2023
@jarrodmillman jarrodmillman merged commit a23f756 into scikit-image:main May 16, 2023
@matusvalo matusvalo deleted the noexcept branch May 16, 2023 03:08
@lagru lagru added the 🔧 type: Maintenance Refactoring and maintenance of internals label May 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🔧 type: Maintenance Refactoring and maintenance of internals
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants