-
-
Notifications
You must be signed in to change notification settings - Fork 25.8k
MAINT Use cython language_level=3 directive #12873
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
Conversation
Should we have an issue with a checklist for all the python2 cruft we still have? |
We could just to have a point of reference, but I don't think there is much left to do. |
ok, you'd know better than me ;) |
@@ -4,6 +4,8 @@ | |||
# Lars Buitinck | |||
# Olivier Grisel <olivier.grisel@ensta.org> | |||
# License: BSD 3 clause | |||
# | |||
# cython: language_level=3str, boundscheck=False, wraparound=False |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if you mean "3str", no that's intentional,
The 3str option enables Python 3 semantics but does not change the str type and unprefixed string literals to unicode when the compiled code runs in Python 2.x
because that uses C strchr
and this was failing otherwise. But yeah, ideally I should investigate how to work around that and make it work with language_level=3
.
what's the status? Wanna fix it up? |
Yes, will try to finish this. |
Yay, after spending one hour, I finally found the absolute import that needed to be replaced by a relative one that was producing the obscure error message in #12873 (comment) Should be ready to review now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice!
LGTM |
This is nice. Just a quick remark, when you have a |
I agree both are likely redundant, but do you have a reference for that (that it's in that order and not say the opposite)? The cython documentation is not too explicit about it... |
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
…)" This reverts commit b2ee0c0.
…)" This reverts commit b2ee0c0.
Closes #12796
Aims to switch to language_level=3 for the generated Cython files.
Also switched to a more concise e.g.
# cython: boundscheck=False
instead of,
@cython.boundscheck(False) # for each function
in places where it could be applied globally.
Specified this on the file level because
sklearn/datasets/_svmlight_format.pyx
still assumes C strings (and so requireslanguage_level="3str"
) which would have required more logic if this was set globally insklearn/_build_utils/__init__.py:maybe_cythonize_extensions
).Marking this as WIP, as there is one remaining issue to fix where the build modules fail to import with e.g.,
possibly related to cython/cython#1953 . Though that issue should have been fixed with cython 0.28 while I used cython 0.29 in my tests.