-
-
Notifications
You must be signed in to change notification settings - Fork 32.1k
GH-106008: Make implicit boolean conversions explicit #106003
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
69781b4
Make boolean conversions in branches explicit
brandtbucher 5289c7f
Specialize UNARY_NOT
brandtbucher 7e5c9df
Remove unused stats
brandtbucher 27bb264
Make UNARY_NOT_BOOL a little bit slicker
brandtbucher 0463633
Replace UNARY_NOT with TO_BOOL
brandtbucher d2932a1
Catch up with main
brandtbucher 47ec38f
Branchless branching
brandtbucher a0bd53a
Add a "boolean conversion" bit to COMPARE_OP
brandtbucher bab539b
More stats for heap types
brandtbucher 757b1cc
Specialize TO_BOOL_ALWAYS_TRUE
brandtbucher f9fa498
Fix refleak and error handling
brandtbucher 0c14344
Catch up with main
brandtbucher d314078
Cleanup
brandtbucher 9aa83b5
blurb add
brandtbucher a76f11d
Docs
brandtbucher c2d4a33
Clean up some commnts
brandtbucher 7638b76
Add cast
brandtbucher 6b4a598
Catch up with main
brandtbucher File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Specialize UNARY_NOT
- Loading branch information
commit 5289c7f69e7e2ba75cafa076da55dd9f179cae7c
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use
value == &_Py_STR(empty)
. The semantics isvalue == ""
, notvalue is ""
.In general I wouldn't use
Py_Is
except when you want the exact semantics of Python'sx is y
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, I mean, we are checking for the identity of the singleton string here. I'll just change it, though.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hypothetically we could have more than one
""
object. I don't think that" ".strip() is ""
is part of the language spec, soPy_Is
doesn't add any safety, just obfuscation.We can also potentially have tagged ints, in which case
Py_Is
would need to become a lot more complex, butvalue == &_Py_STR(empty)
would remain efficient.