Skip to content

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

picnixz
Copy link
Member

@picnixz picnixz commented Aug 9, 2025

@picnixz picnixz force-pushed the feat/timeit/global-setup-137578 branch from 26c22fd to a63c5f1 Compare August 9, 2025 12:30
@picnixz picnixz marked this pull request as ready for review August 9, 2025 12:32
@picnixz picnixz requested a review from AA-Turner as a code owner August 9, 2025 12:32
Comment on lines +123 to +125
*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.
Copy link
Contributor

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.

Copy link
Member Author

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
Copy link
Member Author

@picnixz picnixz left a 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants