-
-
Notifications
You must be signed in to change notification settings - Fork 508
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
Slow completion for existing object with long __repr__
method
#919
Comments
I also experience this issue, though ipython 6.0 . Note that the completion appears to be slower than a single |
For what it's worth, I'm pretty sure it's not the |
Let me precise that this performance issue was been found from IPython completion (since it uses Jedi). Then it sounds reasonable to me that it does work with "executed code" since I don't think IPython gives the full code history to Jedi but the existing objects (but I don't know internals of IPython neither Jedi so don't give to much credits to my guesses). A typical example (from which I actually determined that Jedi is involved) is available here : qtconsole issue #90 |
@ElieGouzien It does obviously work with executed code. It just tries to not execute it. One of the issues you might be having is that Jedi tries to load the corresponding files of code (to improve autocompletion). This might be a lot of work (depending on the size of the library). What do you guys generally say that would be slow? (in seconds) |
@davidhalter this seems to be specifically related to data objects rather than code files - particularly things like Pandas tables or large numpy arrays. It seems something related to jedi is doing something with the data object. It might be something to do with the way IPython uses Jedi? Perhaps some serialization going on? |
@davidhalter In my case I had something like 10-30 s (with custom class). Basically it's as long as computing What happens (I think) is that when |
Ok, I have a patch ! @davidhalter Where should I put a test for that fix ? EDIT : I think I figured out where to put it but I'm still not 100% sure I'm right. See in the pull request #922. |
Anticipate the raise of TypeError from inspect.getfile to prevent the computation of repr() for the error message wich is not used. Useful for some big pandas arrays. Fix tentative of #919.
I've submitted a bug and a PR to Python to try to improve this in the |
Nice! Thanks! |
Hi,
For completion with existing objects it seems that the
__repr__()
method is evaluated for an error message within the inspect module which is afterward caught. This makes the completion as slow as__repr__()
while this evaluation in unnecessary for the user. This method can bee rather slow with big pandas objects or custom class.This as been seen here :
qtconsole issue #90
A minimal code to reproduce it :
And a more convenient working version :
Jedi seems to end here through jedi/evaluate/compiled/mixed.py, line 121.
Maybe making checks before the calling
inspect.getsourcefile()
could fix it, but not I don't know jedi enough to claim it.The text was updated successfully, but these errors were encountered: