Summary
I found rope
wasn't ignoring the files in my virtual environment that were in my workspace directory. This created understandably slow refactoring performance. I added my virtual environment folder to the ignored_resources
in the rope
configuration file config.py
. Immediately after making the change, refactoring performance greatly improved.
Example
Take the folder structure below.
-.venv
-.vscode
--.ropeproject
---config.py
---objectdb
--pythonpackage
---__init__.py
---[other files I want to refactor]
-main.py
Assuming .venv
is the name of your virtual environment, for rope
to ignore it, you need to include .venv
in the ignored_resources
list in the rope
config.py
file. Example shown below.
def set_prefs(prefs):
"""This function is called before opening the project"""
# Specify which files and folders to ignore in the project.
# Changes to ignored resources are not added to the history and
# VCSs. Also they are not returned in `Project.get_files()`.
# Note that ``?`` and ``*`` match all characters but slashes.
# '*.pyc': matches 'test.pyc' and 'pkg/test.pyc'
# 'mod*.pyc': matches 'test/mod1.pyc' but not 'mod/1.pyc'
# '.svn': matches 'pkg/.svn' and all of its children
# 'build/*.o': matches 'build/lib.o' but not 'build/sub/lib.o'
# 'build//*.o': matches 'build/lib.o' and 'build/sub/lib.o'
prefs['ignored_resources'] = ['*.pyc', '*~', '.ropeproject',
'.hg', '.svn', '_svn', '.git', '.tox', '.venv']
search_minimum_by_least_square
it will work all right. If it'smin
, then no; but python is so dynamic that a real smart refactoring is very difficult to achieve (unlike for java). A good tool for that is PyCharm that does an honest job given the difficulty of the task. – Taxi