Skip to content

Conversation

cpcloud
Copy link
Contributor

@cpcloud cpcloud commented Sep 15, 2025

This PR implements proper None checks using is/is not, contains code regenerated from https://github.com/NVIDIA/cuda-python-private/pull/146.

@copy-pr-bot
Copy link
Contributor

copy-pr-bot bot commented Sep 15, 2025

Auto-sync is disabled for ready for review pull requests in this repository. Workflows must be run manually.

Contributors can view more details about this message here.

@leofang
Copy link
Member

leofang commented Sep 15, 2025

/ok to test

@leofang leofang added this to the cuda-python 13-next, 12-next milestone Sep 15, 2025
@leofang leofang added enhancement Any code-related improvements P1 Medium priority - Should do cuda.bindings Everything related to the cuda.bindings module labels Sep 15, 2025
Copy link
Contributor

@mdboom mdboom left a comment

Choose a reason for hiding this comment

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

Just out of curiosity, does this change the code Cython generates, or is it already smart enough to know that a None comparison can be done with a simple pointer comparison?

@cpcloud
Copy link
Contributor Author

cpcloud commented Sep 15, 2025

It does change the code, because == (and !=) must produce behavior equivalent to PyObject_RichCompare. Cython generates the rich comparison call for == and != and generates C code like this:

__pyx_v_x != Py_None

when is not is used to compare None.

@cpcloud cpcloud merged commit f86b3fb into NVIDIA:12.9.x Sep 15, 2025
35 checks passed
@cpcloud cpcloud mentioned this pull request Oct 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cuda.bindings Everything related to the cuda.bindings module enhancement Any code-related improvements P1 Medium priority - Should do

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants