Skip to content

Conversation

alexhutman
Copy link
Contributor

📚 Description

I had an issue when trying to compile a Cython project using Cython's language_level compiler directive (see Cython
docs
as well as the issue linked below for more info) set to 3, and was getting issues because Python2's / operator yielded floor division in this file (float division wouldn't make sense in this context), whereas in Python3 it is always float division.

This commit converts the implicit floor divisions to explicit ones, so that bitsets are able to be used for Cython projects compiled with the language_level=3 compiler directive.

This should not cause any backwards compatibility issues either, as // explicitly designates floor division in both versions of Python.

Closes #34768

📝 Checklist

  • I have made sure that the title is self-explanatory and the description concisely explains the PR.
  • I have linked an issue or discussion.
  • I have created tests covering the changes.
  • I have updated the documentation accordingly.

⌛ Dependencies

N/A

I had an issue when trying to compile a Cython project using Cython's
`language_level` compiler directive ([see Cython
docs](https://cython.readthedocs.io/en/latest/src/userguide/source_files_and_compilation.html#compiler-directives)
as well as [an issue I opened](sagemath#34768) for more info) set to `3`, and was getting issues because Python2's `/`
operator yielded floor division in this file (float division wouldn't
make sense in this context), whereas in Python3 it is always float division.

This commit converts the implicit floor divisions to explicit ones, so
that bitsets are able to be used for Cython `language_level=3`-compiled
projects.

This should not cause any backwards compatibility issues either, as `//`
explicitly designates floor division in both versions of Python.
@github-actions
Copy link

Documentation preview for this PR is ready! 🎉
Built with commit: fd4f7bf

Copy link
Contributor

@dcoudert dcoudert left a comment

Choose a reason for hiding this comment

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

These changes looks good to me. Thanks.

@alexhutman
Copy link
Contributor Author

No problem, thanks for the approval David -- anything else needed on my end to get this merged?

@vbraun vbraun merged commit 4652693 into sagemath:develop Apr 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[bitset_base.pxd] Use integer division
4 participants