-
Notifications
You must be signed in to change notification settings - Fork 243
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
Use slightly more recent IPython API. #305
Conversation
The new ast transformer are a bit more flexible instead of just appending/prepending some code and allow full Python constructs. - you can use ``__code__`` for where the original code should go, and ``__ret__`` - by default it can also mangle all names that start with `___` (3 underscore), if you need some more hygienic templating. The names are still leaked in global namespace but with invalid python indentifiers names starting with `mangle-` (where `-` is invalid in an identifier). This allow us to later clean the namespace manually in the magic. And this also allwo us to also return the original value from the cell, I don't know if this is something desirable, but I added it nonetheless.
Note that i'm writing that as part of trying to investigate a case where it look like the output of the profiler's IPython magic does show all the frame above the root frame where the profiler is started:
But I do not have access to a reproducer. So I'm mostly trying to understand the code, see where this could coming from and suggesting improvements. |
Thanks. BTW, the part that is supposed to trim that off is |
Thanks that is helpful. |
Ok, let's mark that ready for review. I was not able to fix the bug yet and will do in a separate pr. |
Thanks ! |
The new ast transformer are a bit more flexible instead of just appending/prepending some code and allow full Python constructs.
__code__
for where the original code should go, and__ret__
___
(3 underscore), if you need some more hygienic templating. The names are still leaked in global namespace but with invalid python indentifiers names starting withmangle-
(where-
is invalid in an identifier).This allow us to later clean the namespace manually in the magic.
And this also allwo us to also return the original value from the cell, I don't know if this is something desirable, but I added it nonetheless.