After updating to 3.1, PyCharm hangs forever (on OSX 10.9.1, Python 2.7.5) during the "indexing" of packages.
For me this occurs while indexing scipy
(0.13.3). If I unistall scipy
, indexing appears to complete, but then hangs again on "pythonstubs". The UI becomes unresponsive, CPU use is maxed, and I'm unable to do anything and have to force-quit the app.
If I reinstall scipy, PyCharm hangs again at the same spot in the scipy scan (see screen capture of dialog):
FWIW, I can run Python scripts from the system command line (including some that use scipy
and many other packages recently updated or installed) without issue, so the Python installation is sound.
Has anyone had a similar problem or found a way around this one?
In order to stop PyCharm from indexing the 'lib' directory, right-click on this directory and select Mark Directory as, then Excluded. This directory will now no longer be indexed by PyCharm.
Indexing examines the code of your project to create a virtual map of classes, methods, objects, and other code elements that make up your application. This is necessary to provide the coding assistance functionality, search, and navigation instantaneously. After indexing, the IDE is aware of your code.
The problem lies with any regular expression matches that may have been defined to identify TODO items. The Java standard regular expression library used by PyCharm to match these items uses an algorithm of exponential complexity to search for '*.a'
and similar patterns.
Theoretically, it is possible to match any regexp very fast (a linear algorithm exists), > but many developers of regexp libs simply don't bother implementing it.
The same problem exists for the Python re module:
>>> from timeit import timeit
>>> timeit("import re; list(re.finditer('.*a', 'foo' * 10000))", number=1)
0.6927990913391113
>>> timeit("import re; list(re.finditer('.*a', 'foo' * 50000))", number=1)
17.076900005340576
In general, if indexing is taking a long time, or hanging, look to the RegEx in your TODO items and see if you can narrow the scope of matches in order to improve performance.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With