-
-
Notifications
You must be signed in to change notification settings - Fork 31.7k
fix for timeit when the statement is a string and the setup is not (and tests) #49883
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
Comments
The patch and test is here: There were no tests so i added a few of them. The one that breaks Even if the patch is no good perhaps the test could be useful. |
Georg, this was your patch: http://bugs.python.org/issue1533909 I don't think it should have been accepted so readily. It is not No that it is out in the wild, I think all you can do is fix-up the docs. Also, the inner template function should have a func=func argument so |
I'll look at it. |
Issue bpo-11578 added unit tests for timeit.py. Because of this bug, two tests |
Definitely there is a bug. The code of timeit is written to support string stmt and callable setup. Expected that locals available when the function is created, would be available when the function is executed. But this doesn't work. May be it worked in the earlier Python, I don't know. Due to the lack of tests this was unnoticed. Here is simpler patch that fixes the support of callable setup with string stmt. But I like Tim's approach (compile testing function using the single template), it makes the implementation simpler. I'll try to adapt it for current sources. |
Here is more complicated patch, that not only fixes handling of callable setup, but also simplifies the implementation of timeit constructor. |
New changeset 14d1018940cb by Serhiy Storchaka in branch '2.7': New changeset 89de73c0d848 by Serhiy Storchaka in branch '3.4': New changeset faea7c8bcb13 by Serhiy Storchaka in branch '3.5': New changeset fd01cbe4336e by Serhiy Storchaka in branch 'default': |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: