-
-
Notifications
You must be signed in to change notification settings - Fork 25.4k
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
MAINT Directly cimport
interfaces from std::algorithm
#27682
Comments
cimport
new Cython 3 interfaces directlycimport
interfaces from std::algorithm
I am working on this. |
Our minimum supported Cython version is 0.29.33 currently: scikit-learn/sklearn/_min_dependencies.py Line 20 in a5fed0d
Is there a way to use the new way for Cython >= 3 and the old way for Cython < 3? I assume we want to keep supporting Cython < 3 for some time, in case some unintended Cython 3 bugs are discovered. |
I have made a PR #27699 |
Oh, I missed that. I thought we updated to Cython 3.X after the regressions were fixed. I think maintaining code for Cython 0.29.X and Cython 3.X is costly. Since those maintainable changes aren't strictly required. I think we should wait for Cython 3.X to be used by default everywhere. What do you think? |
Is there a reason to support more than one version of cython? I think the cython dependency is different from Numpy or scipy in that the choice of cython version doesn't impact users. Whether you can install a particular version of scikit-learn or not does not depend on the version of cython. (Maybe this is not quite true for those who build scikit-learn from source) The current minimum version of 0.29.x is the previous "major release" of cython, basically like 3.x now. This makes me think we should only support one version and that in the past we've also only supported one version. If there are problems with cython 3 (say the performance regressions come back) then we will have to implement a fix, but that is life. |
I agree with your analysis. I also do not think there's a reason to support multiple major versions of Cython.
I also think we only must support one version of Cython, but we are not pressured to. I am not sure whether all the bugs fixes of Cython 3.X.X will be backported to Cython 0.29.X. For instance, cython/cython#5230 (which was originally met in scikit-learn) just got addressed, but I wonder whether its solution (cython/cython#5233) will be ported to 0.29.X (I am invoking @da-woods to know more about Cython's policy 🙏). I think the upgrade to Cython 3 must be considered with the release of NumPy 2. To me, this necessitates a comprehensive understanding of the changes for the compilation. |
Given the remark of the current development of Cython given in cython/cython#5233 (comment), I am in favor of now using Cython 3 and I think we should update scikit-learns' build system accordingly. What do you think? |
I would say, open a PR bumping the minimum cython version and see what happens? Quickly looking at numpy and scipy, they require Cython 3 on Side-comment: we are using Cython 3 already but we also make sure that our code compiles with Cython 0.29.33. |
@Lambxx: are you interested in upgrading scikit-learn to use Cython 3 at minimum? |
I opened #28259 to gather feed-back on updating Cython minimum supported version to 3.0.8 |
@jjerphan I'm a first-timer and would also like to contribute to this issue. Is the issue regarding upgrading sklearn to use Cython 3 still open? |
Good to know that you are interested. Unfortunately this is already being addressed by #28284. I would recommend looking at the "good first issue" label in the issue tracker. |
FYI We're now using cython=3.0.8 on the |
Some Cython implementations use interfaces from the standard library of C++, namely
std::algorithm::move
andstd::algorithm::fill
fromstd::algorithm
.Before Cython 3, those interfaces had to be imported directly using the verbose syntax from Cython:
scikit-learn/sklearn/metrics/_pairwise_distances_reduction/_radius_neighbors.pyx.tp
Lines 22 to 26 in 5fc67ae
scikit-learn/sklearn/metrics/_pairwise_distances_reduction/_middle_term_computer.pyx.tp
Lines 28 to 33 in 5fc67ae
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: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. 🙂
The text was updated successfully, but these errors were encountered: