-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
gh-137578: support top-level setup statements in Timer
objects
#137587
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
base: main
Are you sure you want to change the base?
Conversation
26c22fd
to
a63c5f1
Compare
*stmt*, *setup* and *global_setup* may also contain multiple statements | ||
separated by ``;`` or newlines, as long as they don't contain multi-line | ||
string literals. |
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.
I know this has been in the docs for a while, but why aren't multi-line strings allowed? A quick test shows the implementation allows them, though I suppose strings inside stmt
or setup
may get indented differently than the user intends.
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.
Because we reindent the user's code by replacing \n
(it's a naive reindentation, not based on textwrap and possibly because of historical reasons). Maybe we should instead use dedent()
followed by indent()
, in which case that could be ok I guess. However, this should be a separate issue.
- carry co_flags obtained from global setup - update timeit() and repeat() functions
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.
Ideally, I want to change the way we create the main() function because I think it'd be cleaner if we used argparse instead.
timeit
#137578📚 Documentation preview 📚: https://cpython-previews--137587.org.readthedocs.build/