| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
There was a problem hiding this comment.
Looks correct, but I'm not keen on the names. Naming is hard, so I don't have much better names.
At least "truthy", rather than just "truth", would suggest Python bool(x) semantics.
Maybe "to_bool"?
Also, can you add some C tests to Python/optimizer_symbols.c for the various operations?
Sorry, something went wrong.
|
|
||
| op(_UNARY_NOT, (value -- res)) { | ||
| sym_set_type(value, &PyBool_Type); | ||
| res = sym_new_truth(ctx, value, true); |
There was a problem hiding this comment.
From casual reading, this looks like an error as the true argument implies that this has the value True.
Maybe rename sym_new_truth as sym_from_truthiness and have false as the argument for NOT and true as the argument for TO_BOOL?
Sorry, something went wrong.
There was a problem hiding this comment.
Or symbolic consts, like TO_BOOL and INVERT?
Sorry, something went wrong.
There was a problem hiding this comment.
I'd like to avoid a double-negative in the arg name (since inverting it from its current meaning would mean something like "not not"). What if I make it an int and use 0 and 1 instead? I feel like a big part of the friction in reading this is the use of true and false as arguments.
Sorry, something went wrong.
There was a problem hiding this comment.
0 /1 or false/true doesn't matter. Good symbolic names is what is needed.
Maybe even use two different functions with different names?
Sorry, something went wrong.
|
I agree the naming is hard. How about JitSymbolBoolOf and sym_new_bool_of? I feel like "truthy" implies that the value can't be falsey ("truth" is a noun, "truthy" is an adjective describing a value's truth). |
Sorry, something went wrong.
|
We can think ahead with the naming too. Soon we’ll have equality and identity as symbols, and we’ll probably want something reasonably consistent (“truth”, “equality”, and “identity” were the planned names). |
Sorry, something went wrong.
Maybe "truthiness" rather than "truthy" then? |
Sorry, something went wrong.
|
I've heard "truthiness" used to describe the boolean value of a non-boolean in a test. Probably more in a javascript context, but for Python as well. |
Sorry, something went wrong.
|
Sounds good, thanks for the suggestions. |
Sorry, something went wrong.
⚠️⚠️⚠️ Buildbot failure ⚠️⚠️⚠️Hi! The buildbot AMD64 CentOS9 NoGIL Refleaks 3.x (tier-1) has failed when building commit 7afa476. What do you need to do:
You can take a look at the buildbot page here: https://buildbot.python.org/#/builders/1610/builds/946 Failed tests:
Summary of the results of the build (if available): == Click to see traceback logsremote: Enumerating objects: 19, done.
remote: Counting objects: 7% (1/14)
remote: Counting objects: 14% (2/14)
remote: Counting objects: 21% (3/14)
remote: Counting objects: 28% (4/14)
remote: Counting objects: 35% (5/14)
remote: Counting objects: 42% (6/14)
remote: Counting objects: 50% (7/14)
remote: Counting objects: 57% (8/14)
remote: Counting objects: 64% (9/14)
remote: Counting objects: 71% (10/14)
remote: Counting objects: 78% (11/14)
remote: Counting objects: 85% (12/14)
remote: Counting objects: 92% (13/14)
remote: Counting objects: 100% (14/14)
remote: Counting objects: 100% (14/14), done.
remote: Compressing objects: 9% (1/11)
remote: Compressing objects: 18% (2/11)
remote: Compressing objects: 27% (3/11)
remote: Compressing objects: 36% (4/11)
remote: Compressing objects: 45% (5/11)
remote: Compressing objects: 54% (6/11)
remote: Compressing objects: 63% (7/11)
remote: Compressing objects: 72% (8/11)
remote: Compressing objects: 81% (9/11)
remote: Compressing objects: 90% (10/11)
remote: Compressing objects: 100% (11/11)
remote: Compressing objects: 100% (11/11), done.
remote: Total 19 (delta 3), reused 3 (delta 3), pack-reused 5 (from 1)
From https://github.com/python/cpython
* branch main -> FETCH_HEAD
Note: switching to '7afa476874b9a432ad6dbe9fb3e65d62f2999f88'.
You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by switching back to a branch.
If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -c with the switch command. Example:
git switch -c <new-branch-name>
Or undo this operation with:
git switch -
Turn off this advice by setting config variable advice.detachedHead to false
HEAD is now at 7afa476874b GH-130415: Use boolean guards to narrow types to values in the JIT (GH-130659)
Switched to and reset branch 'main'
configure: WARNING: no system libmpdecimal found; falling back to bundled libmpdecimal (deprecated and scheduled for removal in Python 3.15)
make: *** [Makefile:2325: buildbottest] Error 2 |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
This adds a symbolic "truth" type to the JIT optimizer, allowing tests like if not x: ... to narrow the value of x based on its type. Currently, it's only implemented for booleans, but I'm working with a few people to open PRs to narrow int and str values as well.
(The diff looks much worse than it is, since this requires adding ctx parameters to a couple of helper functions that are used everywhere. The "real" changes in optimizer_bytecodes.c are limited to _GUARD_IS_FALSE_POP, _GUARD_IS_NONE_POP, _GUARD_IS_TRUE_POP, _TO_BOOL, _TO_BOOL_BOOL, and _UNARY_NOT.