Skip to content
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

Why jedi-vim is too slow compared with ptpython #498

Closed
Congee opened this issue Nov 11, 2015 · 4 comments
Closed

Why jedi-vim is too slow compared with ptpython #498

Congee opened this issue Nov 11, 2015 · 4 comments

Comments

@Congee
Copy link

Congee commented Nov 11, 2015

I know already there is a relevant issue #163 , but watch the gif at first.
ptpython

See? ptpython is blazingly fast the first time it completes numpy, which is considered a large module.
I think the reasons lie behind:

  1. ptpython uses a global cache
  2. VimL is slow compared with Python
  3. ptpython completes at every stroke, making it fast with the next eval.

It doesn't matter for who write daily small scripts and for who edits all the time without leaving vim. How about for those who write small scientific computation scripts?
Any suggestions?

@davidhalter
Copy link
Owner

Hehe. It's fun how you try to argue why it's slow, but essentially you have no idea, because it's a black box :).

You're arguing that ptpython is faster when it comes to completion. This is obviously kind of wrong, because both jedi-vim and ptpython are using Jedi underneath.

The difference is a simple one: ptpython uses Jedi within a shell. Jedi can therefore profit from Python's introspection capabilities (which are obviously fast, e.g. dir(...)), whereas jedi-vim works purely with text (code), which means: No introspection. Theoretically we could execute that code, but that is just a big security issue - think about just executing os.system('rm -rf /'). That's not what you want. Therefore more analysis and therefore CPU time is needed. It's simply not possible to be as fast as ptpython.

However, I still like the fact that you compared the speed of two different Jedi usages :-)

BTW your .GIF is not working.

@Congee
Copy link
Author

Congee commented Nov 11, 2015

Well, that's embarrssing. I've never thought about security. It couldn't be better if there is a way to improve the speed. Thanks for your detailed explanations of instrospection and security. :D

@gerryqd
Copy link

gerryqd commented Jan 20, 2016

Both ptpython and jedi.vim work slow on my environment (win764, cygwin),
On the same machine, the windows version works well.

For the slow case, when it is ptpython, after I input the first letter after the "import " statement, it will takes about 20 seconds to response.

When it was the "jedi.vim", "import" statement works well, but the auto completion will be very slow, after I type the "." after the package name, it will also takes about 20 seconds to get response.

@davidhalter
Copy link
Owner

We have had a lot of reports that Jedi is slow on cygwin. I won't fix it, because I don't even run windows. However it's something that probably has to do with cygwin itself.

blueyed added a commit to blueyed/jedi-vim that referenced this issue Aug 11, 2019
    * pythonx/jedi 60415033...35e5cf2c (106):
      > A small Changelog improvement
      > Cleanup Changelog for the next release
      > Make it possible to access functions that were inherited, see #1347
      > Messed up a Windows test
      > Again a small windows issue fixed.
      > Need to escape the path backslash for windows slashes
      > Make it possible to access properties again
      > A small compatibility fix
      > Fix an issue with type vars that might have been a problem for other things as well
      > Don't add quotes after paths if they are already there
      > A small speed optimization that helps a lot with sys.version_info >= (3, 0) patterns in typeshed
      > Remove an unnecessary isinstance usage
      > Make CompiledValue lazy
      > A python 2 fix
      > Fix an error that occured because of some refactorings
      > Fix one more os.path.join issue
      > Fix more issues with os.path path completion
      > Make join detection much easier
      > Fix some remaining issues with file path completions
      > A few more tests for path completions (join)
      > Fix quote completions for os.path.join path completions
      > Fix first param argument of os.path.join file completions
      > Fix arglist/trailer issues
      > in os.path.join completions, directories should not end in a slash
      > Make some file path completions in os.path.join work
      > Fix os.path.join static value gathering
      > os.path.sep should always have a clear value
      > Fix string name completion for stuff like dirname and abspath
      > Fix bytes issue with file path adding
      > Python 2 compatibility
      > Make __file__ return the correct value
      > Fix string additions when used in certain ways
      > Make string additions work for file path completion
      > Fix interpeter project path
      > Fix the REPL completer for file path completions
      > Fix a few more file name completion cases
      > A first iteration for file path completions
      > Fix a test failure
      > Add Definition.execute, fixes davidhalter#1076
      > Add tests to show that davidhalter#516 is not working, yet
      > List possible Definition.type in its docstring, fixes davidhalter#1069.
      > Start writing the Changelog for 0.15.0
      > 3.8-dev should not be allowed to fail
      > Skip more Python 2 tests
      > Skipping of tests was done the wrong way again
      > Skip the right tests
      > Parameter.kind is not avaialble in Python 3.5
      > Fix Python 2 test issues
      > Add a few docstrings to make some things clearer
      > Add ParamDefinition.kind, fixes #1361
      > Make it possible to format a param to a string, fixes davidhalter#1074
      > Add another test for signature annotations
      > Add Signature.to_string() with proper tests, fixes davidhalter#779, fixes davidhalter#780
      > Test infer_default
      > Use a helper to create definitions
      > Add a execute_annotation option to infer_annotation
      > Test infer_annotation
      > Make it possible for users to infer annotations/defaults
      > A first iteration of adding signatures to the API, fixes #1139
      > Fix a caching issue
      > Forgot the right resolve_stars parameters in one place
      > Cache getting resolved param names
      > Turn around resolve_stars, it shouldn't by default be resolved
      > Remove a class that is not needed anymore
      > Revert "Use __str__ instead of to_string"
      > Fix the last remaining issues with function signature
      > overloaded_functions should be private
      > Use __str__ instead of to_string
      > Better repr for CallSignature
      > Fix some minor signature issues
      > Remove the unused function signature_matches
      > Fix signatures for __init__ calls when used with supers, fixes #1163
      > Fix some issues for args resolving in method calls
      > Remove a bit of code that i sprobably unused
      > Move get_signatures from Function to FunctionMixin
      > Merge the signature changes
      > Remove an import
      > Small refactoring
      > Skipped Python 2 Interpreter tests the wrong way
      > Remove a paragraph in docs that was arguing that stubs and generics (and other things) were not properly supported, fixes davidhalter#1012
      > Fix partial signatures for MixedObject
      > Fix partial signatures, fixes #1371
      > Make sure with a test that the staticmethod signature is also correct
      > Fix classmethod signature, fixes davidhalter#498
      > Deal with annotation on *args and **kwargs correctly, fixes davidhalter#980
      > Use LazyContextWrapper more
      > Very small refactoring
      > Fix for failing assertion on native modules Issue #1354 (#1370)
      > Skip numpydoc tests for Python 2
      > Remove code that didn't mean anything
      > Fix docstrings for wrapped functions, fixes davidhalter#906
      > Fix an isue about dict ordering in Python before 3.6.
      > Make it clearer when get_param is used.
      > A small dataclass refactoring
      > Evaluate annotations for dataclasses when infer is called on param
      > Get inheritance of dataclass right
      > A first working iteration of dataclass signatures, fixes #1213
      > Remove an unused function
      > Dataclass progress
      > Add enum changes to changelog
      > Fix a recursion error about getting metaclasses
      > One test about recursion issues only applied to Python 2
      > Use class filters in instances differently so metaclass plugins work, fixes davidhalter#1090
      > First step in working with metaclasses in plugins, see davidhalter#1090.
      > Refactor the plugin registry
      > Remove classes from plugins and use decorators instead
davidhalter pushed a commit that referenced this issue Aug 11, 2019
    * pythonx/jedi 60415033...35e5cf2c (106):
      > A small Changelog improvement
      > Cleanup Changelog for the next release
      > Make it possible to access functions that were inherited, see #1347
      > Messed up a Windows test
      > Again a small windows issue fixed.
      > Need to escape the path backslash for windows slashes
      > Make it possible to access properties again
      > A small compatibility fix
      > Fix an issue with type vars that might have been a problem for other things as well
      > Don't add quotes after paths if they are already there
      > A small speed optimization that helps a lot with sys.version_info >= (3, 0) patterns in typeshed
      > Remove an unnecessary isinstance usage
      > Make CompiledValue lazy
      > A python 2 fix
      > Fix an error that occured because of some refactorings
      > Fix one more os.path.join issue
      > Fix more issues with os.path path completion
      > Make join detection much easier
      > Fix some remaining issues with file path completions
      > A few more tests for path completions (join)
      > Fix quote completions for os.path.join path completions
      > Fix first param argument of os.path.join file completions
      > Fix arglist/trailer issues
      > in os.path.join completions, directories should not end in a slash
      > Make some file path completions in os.path.join work
      > Fix os.path.join static value gathering
      > os.path.sep should always have a clear value
      > Fix string name completion for stuff like dirname and abspath
      > Fix bytes issue with file path adding
      > Python 2 compatibility
      > Make __file__ return the correct value
      > Fix string additions when used in certain ways
      > Make string additions work for file path completion
      > Fix interpeter project path
      > Fix the REPL completer for file path completions
      > Fix a few more file name completion cases
      > A first iteration for file path completions
      > Fix a test failure
      > Add Definition.execute, fixes #1076
      > Add tests to show that #516 is not working, yet
      > List possible Definition.type in its docstring, fixes #1069.
      > Start writing the Changelog for 0.15.0
      > 3.8-dev should not be allowed to fail
      > Skip more Python 2 tests
      > Skipping of tests was done the wrong way again
      > Skip the right tests
      > Parameter.kind is not avaialble in Python 3.5
      > Fix Python 2 test issues
      > Add a few docstrings to make some things clearer
      > Add ParamDefinition.kind, fixes #1361
      > Make it possible to format a param to a string, fixes #1074
      > Add another test for signature annotations
      > Add Signature.to_string() with proper tests, fixes #779, fixes #780
      > Test infer_default
      > Use a helper to create definitions
      > Add a execute_annotation option to infer_annotation
      > Test infer_annotation
      > Make it possible for users to infer annotations/defaults
      > A first iteration of adding signatures to the API, fixes #1139
      > Fix a caching issue
      > Forgot the right resolve_stars parameters in one place
      > Cache getting resolved param names
      > Turn around resolve_stars, it shouldn't by default be resolved
      > Remove a class that is not needed anymore
      > Revert "Use __str__ instead of to_string"
      > Fix the last remaining issues with function signature
      > overloaded_functions should be private
      > Use __str__ instead of to_string
      > Better repr for CallSignature
      > Fix some minor signature issues
      > Remove the unused function signature_matches
      > Fix signatures for __init__ calls when used with supers, fixes #1163
      > Fix some issues for args resolving in method calls
      > Remove a bit of code that i sprobably unused
      > Move get_signatures from Function to FunctionMixin
      > Merge the signature changes
      > Remove an import
      > Small refactoring
      > Skipped Python 2 Interpreter tests the wrong way
      > Remove a paragraph in docs that was arguing that stubs and generics (and other things) were not properly supported, fixes #1012
      > Fix partial signatures for MixedObject
      > Fix partial signatures, fixes #1371
      > Make sure with a test that the staticmethod signature is also correct
      > Fix classmethod signature, fixes #498
      > Deal with annotation on *args and **kwargs correctly, fixes #980
      > Use LazyContextWrapper more
      > Very small refactoring
      > Fix for failing assertion on native modules Issue #1354 (#1370)
      > Skip numpydoc tests for Python 2
      > Remove code that didn't mean anything
      > Fix docstrings for wrapped functions, fixes #906
      > Fix an isue about dict ordering in Python before 3.6.
      > Make it clearer when get_param is used.
      > A small dataclass refactoring
      > Evaluate annotations for dataclasses when infer is called on param
      > Get inheritance of dataclass right
      > A first working iteration of dataclass signatures, fixes #1213
      > Remove an unused function
      > Dataclass progress
      > Add enum changes to changelog
      > Fix a recursion error about getting metaclasses
      > One test about recursion issues only applied to Python 2
      > Use class filters in instances differently so metaclass plugins work, fixes #1090
      > First step in working with metaclasses in plugins, see #1090.
      > Refactor the plugin registry
      > Remove classes from plugins and use decorators instead
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants