Skip to content
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-119164: Make timeit CLI function available from python #119165

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

WolfDWyc
Copy link

@WolfDWyc WolfDWyc commented May 19, 2024

Resolves #119164.

Currently did not verify tests, and have some changes from @terryjreedy to add, so this is still a draft.

Copy link

cpython-cla-bot bot commented May 19, 2024

All commit authors signed the Contributor License Agreement.
CLA signed

@bedevere-app
Copy link

bedevere-app bot commented May 19, 2024

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

@bedevere-app
Copy link

bedevere-app bot commented May 19, 2024

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

@WolfDWyc WolfDWyc marked this pull request as draft May 19, 2024 00:04
Lib/timeit.py Outdated Show resolved Hide resolved
Lib/timeit.py Outdated Show resolved Hide resolved
Lib/timeit.py Outdated
raw_timings = t.repeat(repeat, number)
except:
t.print_exc()
run(stmt, setup, timer, repeat, number, time_unit, bool(verbose))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
run(stmt, setup, timer, repeat, number, time_unit, bool(verbose))
_run(t, repeat, number, time_unit, verbose)

Lib/timeit.py Outdated Show resolved Hide resolved
Lib/timeit.py Outdated Show resolved Hide resolved
Copy link
Contributor

@nineteendo nineteendo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add private wrapper

Lib/timeit.py Outdated Show resolved Hide resolved
Lib/timeit.py Outdated Show resolved Hide resolved
Lib/timeit.py Outdated Show resolved Hide resolved
@terryjreedy
Copy link
Member

I plan to work on this later today after working on another PR. This will need a news entry but not now.

"Weird" is irrelevant. It is common on unix that -vv give even more output than -v. My intention when I suggested an issue/PR on Discourse was that CLI output be unchanged lest something break. Doing so would be a complete separate issue which I have little interest in and which I would not do. This issue is about adding a more convenient way to get the same output interactively after importing timeit.

@nineteendo
Copy link
Contributor

nineteendo commented May 19, 2024

Sorry for the stream of suggestions. I suggest applying them in batch from the files menu: https://github.com/python/cpython/pull/119165/files

@WolfDWyc
Copy link
Author

I plan to work on this later today after working on another PR. This will need a news entry but not now.

"Weird" is irrelevant. It is common on unix that -vv give even more output than -v. My intention when I suggested an issue/PR on Discourse was that CLI output be unchanged lest something break. Doing so would be a complete separate issue which I have little interest in and which I would not do. This issue is about adding a more convenient way to get the same output interactively after importing timeit.

Sorry, I didn't understand I was breaking something with the current code. Missed the documentation part where -v stacks, I just thought @nineteendo wanted it to stack, and called that addition weird.

I have no intention changing the CLI usage at all. Completely agree with you.

@nineteendo
Copy link
Contributor

Can you address my feedback now?

@WolfDWyc
Copy link
Author

Yes, addressing that now!
Also would like some advice on what to put in the docstring of run()

@WolfDWyc
Copy link
Author

Also, I fixed best being calculated twice, but it seems like that was the case even before my change.

…d twice, and add internal _run function that accepts a timeit Timer so main can access it.
@bedevere-app
Copy link

bedevere-app bot commented May 24, 2024

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

@WolfDWyc
Copy link
Author

Addressed the changes and happy to get another review. The tests should pass but I'm wondering how to change the tests specifically for run(). Will work on this more this Saturday.

Copy link
Contributor

@nineteendo nineteendo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me

Lib/timeit.py Outdated Show resolved Hide resolved
@bedevere-app
Copy link

bedevere-app bot commented Jun 5, 2024

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

Co-authored-by: Nice Zombies <nineteendo19d0@gmail.com>
@bedevere-app
Copy link

bedevere-app bot commented Jun 5, 2024

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label 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.

Make timeit CLI function available from python
3 participants