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
Transform code before %prun/%%prun runs #4008
Conversation
Should it also apply the AST transformers? It's largely academic from IPython's point of view, as we don't have any ourselves, but Sympy & Sage might. I don't know how easy that is with the profiler code, though. Also, should there be/can there be a test for this? |
At the moment Sage doesn't have AST transformers. I think the code modifications are a bit more to do the AST transforms, because currently you run the code from a string. And the same change should probably be made to timeit if it is done here. A test seems fair enough. Is there a test for the %timeit change I could modify? I didn't see one in Fernando's commit. |
%timeit and %time already do AST transforms.
|
But yes, it's probably OK to leave AST transforms out of %prun for the moment - it would be a fair bit of extra complexity, and it can always be done in another PR. Pinging @asmeurer - does Sympy use any AST transforms? |
No, I never got around to updating the code. |
The automatic symbols and int sympification from https://github.com/sympy/sympy/blob/master/sympy/interactive/session.py are what need to be updated. I don't really understand what the question is here for me. |
Jason is updating %prun to handle syntax transformations, but I think we're leaving AST transformations out for the time being. I just wanted to keep you in the loop of where AST transformations do and don't work at present. |
Okay, I think I did the test correctly. I wasn't sure what the skipif decorator on the other prun test was for, but it looked important, so I copied it over. Is it needed? |
Yep, that looks sound. I'll merge once Travis gives it the OK. Thanks! Yes, the skipif decorator is needed. profile may not always be there, for some license-y reasons I don't know the details of. |
Is there stable and dev branches right now? It would be great if this was included in the next bugfix release (it would eliminate a patch we are applying to IPython in Sage). Or is the plan to just forge ahead with one release branch? |
Yes, there's a 1.x branch, and I'd be happy for this to get backported. But we're also aiming to have faster major releases, so 2.0 will probably be this winter. Merging to master, then I'll work out whether & how to backport. |
Transform code before %prun/%%prun runs
@takluyver I set the |
I'll just do it. |
Backported. |
@bfroehle thanks for tagging it with backport, and yes, as @takluyver did, it's nice to get these backports out of the way so we have less work to do for those bug fix releases. Cherry picking a squashed version of a PR is fair game, and we have a script it |
Transform code before %prun/%%prun runs
This makes it so that prun works with IPython-specific syntax (e.g.,
%prun %logon
). This mirrors the change @fperez made in commit 3ac024c for the timeit magic.