Closed
Conversation
Partial fix for cython#7521. This came up in a particular scikit-image microbenchmark so almost certainly isn't the only thing. But it looks like this particular function relies heavily on unused branches being eliminated so really wants to be inlined. On the scikit-image microbenchmark, it's now actually faster with the shared utility code than without. I'm not sure why but possibly just the effect of the `inline` keyword. The shared utility module itself doesn't change size at all with this fix. I don't really like the code duplication but I think it's worth it at least for now.
This was referenced Mar 8, 2026
Contributor
Author
Thinking about this more, I wonder if this is better solved by moving this function to the C utility code. It's all very simple and were aren't really using Cython to do any Python object handling or anything. So moving it to C would just give better control of how it's included. |
da-woods
added a commit
to da-woods/cython
that referenced
this pull request
Mar 9, 2026
Partial fix for cython#7521. This came up in a particular scikit-image microbenchmark so almost certainly isn't the only thing. But it looks like this particular function relies heavily on unused branches being eliminated so really wants to be inlined. On the scikit-image microbenchmark, it's now actually faster with the shared utility code than without. I'm not sure why but possibly just the effect of the inline keyword. The shared utility module itself doesn't change size at all with this fix (despite moving it to C) Alternative to cython#7557
Contributor
Author
|
#7558 is an alternative version of this translated to C rather than duplicated. Performance-wise it's basically identical I think |
Contributor
Agreed. Closing this PR since it's superseded by #7558 |
da-woods
added a commit
that referenced
this pull request
Mar 9, 2026
Partial fix for #7521. This came up in a particular scikit-image microbenchmark so almost certainly isn't the only thing. But it looks like this particular function relies heavily on unused branches being eliminated so really wants to be inlined. On the scikit-image microbenchmark, it's now actually faster with the shared utility code than without. I'm not sure why but possibly just the effect of the inline keyword. The shared utility module itself shrinks by 32bytes with this fix. Alternative to #7557. I prefer this version because it has less duplication but there's some risk of errors in the translation to C
scoder
pushed a commit
that referenced
this pull request
Mar 21, 2026
Partial fix for #7521 Backport to 3.2.x of #7558 This came up in a particular scikit-image microbenchmark so almost certainly isn't the only thing. But it looks like this particular function relies heavily on unused branches being eliminated so really wants to be inlined. On the scikit-image microbenchmark, it's now actually faster with the shared utility code than without. I'm not sure why but possibly just the effect of the inline keyword. The shared utility module itself shrinks by 32bytes with this fix. Alternative to #7557. I prefer this version because it has less duplication but there's some risk of errors in the translation to C.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Partial fix for #7521.
This came up in a particular scikit-image microbenchmark so almost certainly isn't the only thing. But it looks like this particular function relies heavily on unused branches being eliminated so really wants to be inlined.
On the scikit-image microbenchmark, it's now actually faster with the shared utility code than without. I'm not sure why but possibly just the effect of the
inlinekeyword.The shared utility module itself doesn't change size at all with this fix.
I don't really like the code duplication but I think it's worth it at least for now.