Skip to content
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

Make data_structures/bitset_base.pxd use explicit integer division #35313

Merged
merged 2 commits into from
Apr 6, 2023

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
@mkoeppe mkoeppe added this to the sage-10.0 milestone Apr 7, 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