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

pyisnothing function? #149

Closed
stevengj opened this issue Apr 12, 2022 · 1 comment
Closed

pyisnothing function? #149

stevengj opened this issue Apr 12, 2022 · 1 comment

Comments

@stevengj
Copy link
Member

Seems pretty common to check if something is None in Python, but it is a bit awkward (and probably suboptimal) to check pyconvert(Bool, object == Py(nothing)). (Since None is a singleton object in Python, you can just check pointer equality.)

@cjdoris
Copy link
Collaborator

cjdoris commented Apr 21, 2022

You can already do one of:

pyis(x, pybuiltins.None)  # 1ns
@py x === None  # 1ns
pyis(x, nothing)  # 20ns

@cjdoris cjdoris closed this as completed Apr 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants