Pylance-release: Pylance uses 100% CPU and runs very long on files using sympy

Created on 12 Feb 2021  路  7Comments  路  Source: microsoft/pylance-release

Environment data

needs investigation partial stubs

Most helpful comment

We are exploring the use of partial type stubs for this package. By stubbing some of the key types, it looks like we'll be able to dramatically reduce the computational cost of inferring the remaining types.

All 7 comments

We released 2021.2.2 yesterday, and your bug is reported on 2021.2.1, can you retry with the latest version?

My guess is that it won't, though, as your logs say:

[BG(1)]   checking: /home/jens/pylance_issue/test.py (70475ms)
[Info  - 15:43:15] [BG(1)] Long operation: checking: /home/jens/pylance_issue/test.py (70475ms)
[BG(1)] analyzing: /home/jens/pylance_issue/test.py (70478ms)
[Info  - 15:43:15] [BG(1)] Long operation: analyzing: /home/jens/pylance_issue/test.py (70478ms)

Is test.py exactly your code snippet? It's hard for me to imagine that checking that file takes 70 seconds...

Hi, thanks for the reply!
Yup, it's the same with 2021.2.2 and as mentioned above I also experience the same with the insiders version.
Yes, this is exactly the file. I'm in an otherwise empty folder and this is the only file open.
I know this whole thing is weird, but it happens exactly as I'm reporting it. I isolated the issue with sympy by commenting out lots of other imports in a larger project; none of those seemed to have a similar problem...

This is related to https://github.com/microsoft/pyright/issues/1439. I don't see any obvious ways to make this work better. I offered some suggestions in the linked bug, but none of them are great solutions unfortunately.

We're looking into this, seems like a case for profiling.

This is related to microsoft/pyright#1439. I don't see any obvious ways to make this work better. I offered some suggestions in the linked bug, but none of them are great solutions unfortunately.

Thanks for the link! Indeed, disabling useLibraryCodeForTypes circumvents the issue. Of course, one also loses useful functionality :/
Since sympy was the only problematic package for me, I'm now using

sympy = importlib.import_module('sympy')

as a workaround to prevent pylance from analyzing it, but keeping useLibraryCodeForTypes True otherwise.

We are exploring the use of partial type stubs for this package. By stubbing some of the key types, it looks like we'll be able to dramatically reduce the computational cost of inferring the remaining types.

That sounds great! Thank you so much for working on this, I'm looking forward to trying it out!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ynouri picture ynouri  路  3Comments

yankyhoffman picture yankyhoffman  路  5Comments

BrunoBlanes picture BrunoBlanes  路  4Comments

flaree picture flaree  路  4Comments

andyljones picture andyljones  路  5Comments