davidhalter / jedi-vim

Using the jedi autocompletion library for VIM.
MIT License
5.28k stars 370 forks source link

Reuse jedi.Script (per environment)? #952

Closed blueyed closed 3 years ago

blueyed commented 5 years ago

I've noticed that when comparing two lists of definitions for the same "place" it will not compare equal, because self._inference_state (an object, apparently recreated always?) is also included in __eq__: https://github.com/jedi/jedi/blob/9cdc4d6039d0df70aa759fa23371ea92c5c8fc72/jedi/api/classes.py#L603-L607

This appears due to using a new jedi.Script instance.

Therefore I've wondered if it would be good to re-use a single Script instance in jedi-vim (per environment)?

Otherwise I'll probably just use a custom method for comparison. (it's for the usages, where I want to re-use a quickfix list for the same definitions)

@davidhalter

blueyed commented 5 years ago

It uses jedi.settings though also for additional modules etc: https://github.com/blueyed/jedi-vim/blob/50abb5e95a8d496dbda7b04a9bb78e4a6cd0a968/pythonx/jedi_vim.py#L205-L209

blueyed commented 5 years ago

FWIW I've used this for now: https://github.com/davidhalter/jedi-vim/pull/851/files#diff-795a775c12a507b481a669a1ead1839eR473-R483 (_same_definitions).

I think that's probably fair..?

davidhalter commented 5 years ago

Why don't you clear always?

Reusing Script is definitely not a good idea. It can be reused, but not if the code is changed. So it only make sense to reuse it for e.g. goto and completions.

davidhalter commented 3 years ago

This is now implemented. Happy to get some feedback about the current solution. If there's none, I will probably close here at some point.

davidhalter commented 3 years ago

The Script is now not reused, but a lot of other things are. I think the Jedi API is now in the right shape.