vscode-python: renaming python variable is too slow

Environment data

  • VS Code version: 1.47.1
  • Extension version (available under the Extensions sidebar): v2020.7.94776
  • OS and version: MacOS 10.14.6
  • Python version (& distribution if applicable, e.g. Anaconda): 3.7.4
  • Type of virtual environment used (N/A | venv | virtualenv | conda | …): N/A
  • Value of the python.languageServer setting: Microsoft

Expected behaviour

Rename a variable succeed in 1 second.

Actual behaviour

Rename a variable succeed in 50 seconds

Steps to reproduce:

[NOTE: Self-contained, minimal reproducing code samples are extremely helpful and will expedite addressing your issue]

  1. Find a python script with about 400 lines.
  2. Right-click a variable and select rename, key in the new name, and press the “Enter” button.

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 5
  • Comments: 28 (8 by maintainers)

Most upvoted comments

I close this issue because it’s resolved by using "python.languageServer": "Pylance" as the language server. The renaming can be done immediately even in a file with ~3000 lines of Python code.

@MaxFBurg You may have to file this on the language servers depending on which one you are using. If you have Jedi as the language server it uses rope for refactoring. rope is outdated and slow. At this point we are transitioning people from Jedi to JediLSP, so try JediLSP as the language server setting and see if it helps. If you still feel it is slow then please file a bug on https://github.com/davidhalter/jedi

If the language server is Microsoft, this will also be deprecated soon. So replace that with Pylance (you may need to install pylance extension), and see if it helps. If Pylance is slow then please file a bug on https://github.com/microsoft/pylance-release

Issue for Pylance is already open here: https://github.com/microsoft/pylance-release/issues/882

Same for me, renaming variables takes more than 10-20 sec. I set Pylance everywhere and removed rope.

Same for me, especially when renaming functions, classes, arguments.

Yeah, just to clarify, changing from Jedi to Pylance didn’t change the renaming speed for me

Hey there, I also use pylance and renaming symbols takes >30sec.

While I didn’t have the time to assemble a minimal repro project, yet, the problem definitely is not solved for me with pylance.

In my case, it was slow because of having a folder with a large number of files in the root directory. I excluded the files following this, restarted VSCode and it seemed to work 😄

I have noticed that the renaming of a function argument is much slower than a variable defined in a function. The former takes ~ 5 seconds, and the latter is pretty instant. (This is with pylance now)

@karthiknadig I have tried pylance, but that didn’t really improve waiting times. Do I have to activate it somehow? Is it enough to just remove rope from my python environment?