Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why Pylint is too slow while pep8 just takes a second to check the same code?

I do not understand why pylint takes about 5 minutes to check my code, where pep8 takes only 1 sec.

I use Mac and I have pylint 1.8.4 installed through conda install -c conda-forge pylint. Pylint is very slow either I use Terminal or the Spyder editor. I tried creating a config file .pylintrc but it didn't make a difference to the speed.

How can I accelerate the Pylint speed? Thank you.

like image 388
Sahar Avatar asked Jul 23 '18 23:07

Sahar


People also ask

How can I make Pylint faster?

Pylint is a great linter, but it can be horrendously slow to run on anything but the most trivial of code bases. While there are a multitude of configuration options that can be tweaked, the simplest approach is to only lint files that you have edited.

Is Pylint a PEP8?

Pylint is a python linter which checks the source code and also acts as a bug and quality checker. It has more verification checks and options than just PEP8(Python style guide). This is the most commonly used tool for linting in python.

Why is Pylint used?

Pylint analyses your code without actually running it. It checks for errors, enforces a coding standard, looks for code smells, and can make suggestions about how the code could be refactored. Pylint can infer actual values from your code using its internal code representation (astroid).


1 Answers

You can speed up pylint by spawning multiple processes and checking files in parallel. This functionality is exposed via the -j command-line parameter. If the provided number is 0, then the total number of CPUs will be autodetected and used. From the output of pylint --help:

-j <n-processes>, --jobs=<n-processes>
    Use multiple processes to speed up Pylint. Specifying
    0 will auto-detect the number of processors available
    to use. [current: 1]
like image 66
Eugene Yarmash Avatar answered Oct 15 '22 18:10

Eugene Yarmash