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
input_prefilter hook not called #4709
Comments
For the record, I think this came from http://stackoverflow.com/questions/20633985/ipython-input-prefilter/20634792#20634792 as the delta of time between this issues and the SO question is 7 minutes. |
Sorry, I am in despair. |
No problem, I'm not an expert on this part of the code and most of the other core dev are asleep at this time, they should be available in a few hours. You can also pre-describe exactly what you want to do it might help ! |
I am writing a profiling extension for ipython which will measure resource usage of each executed line. In [1]: %profile In [2]:a = [a**a for a in range(100)] In [3]:%stats.cpu I am using pre_prompt_hook and pre_run_code_hook in an object to achieve this. But the trick is NOT measuring anything when you call methods and attributes in %stats object which holds the profiling data. So I need some kind of a hook which runs BEFORE the pre_run_code_hook and gives me the ability to temporary disable profiling when i call %stats magic. It's not very clear how to add custom input transformer, as the page only describes how to declare one, maybe I am missing something ? |
I guess you're talking about this page? http://ipython.org/ipython-doc/stable/config/inputtransforms.html Looking back at it, I agree it's not very clear how to add an input transformer. The closest it gets to describing that is this sentence: "An InteractiveShell instance actually has two IPythonInputSplitter instances, as the attributes input_splitter, to tell when a block of input is complete, and input_transformer_manager, to transform complete cells. If you add a transformer, you should make sure that it gets added to both." From an extension, that would look something like this:
Note that you have to decide which of
You can also define AST transforms, which can inspect and modify the parsed Python code before it is executed. |
That's exactly what I need. Thanks alot. That also gives me the idea that maybe |
If no-one has complained until now, there's probably no-one using the hook, so we might just get rid of it to keep things simple. |
It's always exciting to be the first :) So, should I close the issue then ? |
I'll improve the docs a bit and close it from the commit. |
Our code already doesn't call this hook (as pointed out in ipythongh-4709), and probably hasn't for some time, so it seems ~no-one is relying on it. We have much more powerful APIs to do the same thing.
Various docs fixes * Tweak exclude patterns, which were accidentally excluding qt.console.frontend_widget * Added example of adding input transformers (#4709) * Tidied up and added some module docstrings, now that we're using the first line in the API index * Update the inputsplitter module docstring, which was rather out of date. * Fix some header levels introduced in #4265 * pyreadline is apparently no longer mandatory on Windows (#4544)
Our code already doesn't call this hook (as pointed out in ipythongh-4709), and probably hasn't for some time, so it seems ~no-one is relying on it. We have much more powerful APIs to do the same thing.
Remove input_prefilter hook closes ipython#4709
Various docs fixes * Tweak exclude patterns, which were accidentally excluding qt.console.frontend_widget * Added example of adding input transformers (ipython#4709) * Tidied up and added some module docstrings, now that we're using the first line in the API index * Update the inputsplitter module docstring, which was rather out of date. * Fix some header levels introduced in ipython#4265 * pyreadline is apparently no longer mandatory on Windows (ipython#4544)
There is an input_prefilter hook in IPython documentation, but judging from the source it is not called anywhere.
The text was updated successfully, but these errors were encountered: