MAINT Use cython language_level=3 directive#12873
MAINT Use cython language_level=3 directive#12873jnothman merged 8 commits intoscikit-learn:masterfrom
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 ;) |
| # 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.
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. |
|
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... |
|
|
…)" 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=Falseinstead of,
@cython.boundscheck(False) # for each functionin places where it could be applied globally.
Specified this on the file level because
sklearn/datasets/_svmlight_format.pyxstill 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.