Skip to content

Timeit issue #106

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

Closed
henryiii opened this issue Dec 5, 2018 · 2 comments
Closed

Timeit issue #106

henryiii opened this issue Dec 5, 2018 · 2 comments

Comments

@henryiii
Copy link

henryiii commented Dec 5, 2018

I believe the code in Let's make a giant string! is incorrect; that's not how you use the timeit module. (I would normally use IPython's %%timeit magic). You have to give the function to timeit in some way where it does not evaluate the function before it gets to the timeit call!

Something like this would work:

timeit.timeit('add_string_with_plus(10000)', number=1000, globals=globals())
@satwikkansal
Copy link
Owner

Ah, never thought of that. Thanks for pointing it out @henryiii, will fix it 👍

And it'd be nice to see the deltas b/w the previous timeit use, and the newer approach. If the different is significant enough, we can make another wtf out of it!

@satwikkansal
Copy link
Owner

Fixed :)

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

No branches or pull requests

2 participants