Uh oh!
There was an error while loading. Please reload this page.
gh-115999: Add free-threaded specialization for TO_BOOL - #126616
Conversation
* None / bool / int / str are immutable types, so they is thread-safe. * list is mutable, but by using ``PyList_GET_SIZE`` we can make it as thread-safe.
Uh oh!
There was an error while loading. Please reload this page.
TO_BOOLTO_BOOLUh oh!
There was an error while loading. Please reload this page.
TO_BOOLTO_BOOL| if (PyAnySet_CheckExact(value)) { | ||
| return SPEC_FAIL_TO_BOOL_SET; | ||
| } | ||
| if (PyTuple_CheckExact(value)) { |
There was a problem hiding this comment.
Maybe not for this PR to address, but why is the tuple type handled here? I see no specialization for tuple (or did I miss something?). Tuple is immutable, so it should be relatively easy to add
There was a problem hiding this comment.
IIRC, we added specializaiton based on metric that is measured at https://github.com/faster-cpython/benchmarking-public.
I am not sure how many tuple cases are actually existed.
There was a problem hiding this comment.
I agree that tuple case is easy to add but that would be based on how many boolean operations are existed for the tuple at the real world workload.
There was a problem hiding this comment.
Thanks for doing this! Looks good overall. In addition to the comment inline, we're also going to need to update _GUARD_TYPE_VERSION to load tp->tp_version tag using an FT_ATOMIC_LOAD_UINT32_RELAXED.
My review raced with your updates, I hope the comments still make sense.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
When you're done making the requested changes, leave the comment: |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
corona10
commented
Nov 16, 2024
I have made the requested changes; please review again |
Thanks for making the requested changes! @markshannon, @mpage: please review the changes made to this pull request. |
Mark, I am okay with surrounding Please take a look :) |
mpage
left a comment
There was a problem hiding this comment.
I still don't understand the rationale for keeping the gotos, but I care more about seeing this PR move forward. Accepting to unblock.
corona10
commented
Nov 21, 2024
When you're done making the requested changes, leave the comment: |
corona10
commented
Nov 21, 2024
I am merging this PR, @markshannon. Please let me know if we have to handle more things in the future PRs. Matt and I will try to adjust what you concerns :) cc @mpage |
PyList_GET_SIZEwe can make it as thread-safe.--disable-gilbuilds #115999