-
-
Notifications
You must be signed in to change notification settings - Fork 31.5k
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
gh-131738: optimize builtin any/all/tuple calls with a generator expression arg #131737
Conversation
Misc/NEWS.d/next/Core_and_Builtins/2025-03-25-20-38-06.gh-issue-131738.eCb0OQ.rst
Outdated
Show resolved
Hide resolved
I don't think |
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.
Very cool! Any plans to do this for set
or list
?
dict
/max
/min
/sum
are trickier, but may be worth exploring too.
When you're done making the requested changes, leave the comment: |
This should fix the JIT builds: diff --git a/Tools/jit/_targets.py b/Tools/jit/_targets.py
index aa2b56abf44..73a4210eee0 100644
--- a/Tools/jit/_targets.py
+++ b/Tools/jit/_targets.py
@@ -522,7 +522,14 @@ def get_target(host: str) -> _COFF | _ELF | _MachO:
args = ["-fms-runtime-lib=dll"]
target = _COFF(host, args=args)
elif re.fullmatch(r"x86_64-.*-linux-gnu", host):
- args = ["-fno-pic", "-mcmodel=medium", "-mlarge-data-threshold=0"]
+ args = [
+ # Jump tables generate R_X86_64_32S relocations, which assume a
+ # signed 32-bit address space:
+ "-fno-jump-tables",
+ "-fno-pic",
+ "-mcmodel=medium",
+ "-mlarge-data-threshold=0",
+ ]
target = _ELF(host, args=args)
else:
raise ValueError(host) |
The overall approach looks good. Do you have stats for this PR? |
The latter three would be nice wins. |
I have made the requested changes; please review again. |
Thanks for making the requested changes! @brandtbucher: please review the changes made to this pull request. |
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.
Looks good. You can revert the JIT change, it's not needed anymore.
(Also I'm running JIT benchmarks just because I'm curious, but no need to block on those results at all.)
@@ -19,6 +19,8 @@ | |||
#include "pycore_warnings.h" // _PyErr_WarnUnawaitedCoroutine() | |||
|
|||
|
|||
#include "opcode_ids.h" // RESUME, etc |
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.
Is this needed?
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.
Yes, I had to remove this include from another header so it needs to be included when needed.
(Also, I think you need to |
Co-authored-by: Brandt Bucher <[email protected]>
This PR implements the optimization described in faster-cpython/ideas#545.