You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Python 3.12 runs much slower than Python 3.11 #1496
I suspect it's the large dict literal specifically that is the issue there. It sounds like in 3.12 it is reporting a debugger "line" event (which the debugger then has to process to check for breakpoints etc) for every subexpression in the literal, whereas before it was treated as a single atomic statement?
If so, then this is to be expected - settrace-based Python debugging is inherently slow (~20x overhead per line of pure Python code, such as here). However, we're working on debugpy v2 utilizing the new sys.monitoring API in Python 3.12 for near-zero-overhead debugging; that should address this issue. And I think we should add this import as one of the test cases for that.
Pavel Minaev (@int19h) it sounds like this will take a bit until it is ready. is there any quick fix/work-around for this? it also appears to affect spacy.
0.23384420000002137
0.01s - Debugger warning: It seems that frozen modules are being used, which may
0.00s - make the debugger miss breakpoints. Please pass -Xfrozen_modules=off
0.00s - to python to disable frozen modules.
0.00s - Note: Debugging will proceed. Set PYDEVD_DISABLE_FILE_VALIDATION=1 to disable this validation.
15.49023370000009
Python 3.11 takes ~0.03s vs. 0.05s, so even without the debugger, Python 3.11 seems to be an order of magnitude faster. But the difference is much more striking with the debugger.
FYI for anyone considering this solution, unfortunately compressing the dict into a single line has created a new problem for us, it causes coverage report on Python 3.12 to use excessive amounts of memory (in our case more than 20 GB).
causes coverage report on Python 3.12 to use excessive amounts of memory
For the record, this issue (coveragepy/coveragepy#1785) should be gone with Python 3.12.4 thanks to python/cpython#119118, so the practicality of one-line workarounds should be improved. That is relevant since the original issue continues to exist in Python 3.12.4 (long runtime importing large dicts with debugger attached)
I have a similar problem with module python-opcua.
The simple following script in vscode debugger runs in 2.7 seconds using Python 3.11.2 but 68 seconds with Python 3.12.5.
from opcua import Server
server = Server()
OS Linux (Debian 12)
VsCode 1.92.2
Python Debugger 2024.10.0
I am currently debugging the repository langgenius/dify and am encountering a similar issue with the latest version, where the project takes an unusually long time to start (approximately 5 minutes) on my M1 Pro machine.
I would like to understand the underlying cause of this delay and request guidance on how to resolve it.
Environment Details:
Python Version: 3.12.5
Operating System: macOS 15.0
Chip: Apple M1 Pro
Thank you for your assistance!
Feel free to let me know if you would like any additional information.
Is there an approximate timetable for when we can start developing with vscode and devcontainer again? Since we are dependent on 3.12, vscode and devcontainer with the delays are unfortunately completely useless at the moment. That is not efficient working.
This issue should be fixed in the latest build of debugpy. It should ship with VS code in a future version of the Python Debugger Extension or you can install your own debugpy from pypi
Activity
int19h commentedon Jan 22, 2024
I suspect it's the large dict literal specifically that is the issue there. It sounds like in 3.12 it is reporting a debugger "line" event (which the debugger then has to process to check for breakpoints etc) for every subexpression in the literal, whereas before it was treated as a single atomic statement?
If so, then this is to be expected - settrace-based Python debugging is inherently slow (~20x overhead per line of pure Python code, such as here). However, we're working on debugpy v2 utilizing the new sys.monitoring API in Python 3.12 for near-zero-overhead debugging; that should address this issue. And I think we should add this import as one of the test cases for that.
lsmith77 commentedon Jan 23, 2024
Pavel Minaev (@int19h) it sounds like this will take a bit until it is ready. is there any quick fix/work-around for this? it also appears to affect spacy.
allow python 3.11 until is fixed microsoft/debugpy#1496
bersbersbers commentedon Mar 15, 2024
I think the original issue has been fixed by emoji v2.10.1. For anyone working on this, here's another example:
bug.py:Then run:
For me, this prints
Python 3.11 takes ~0.03s vs. 0.05s, so even without the debugger, Python 3.11 seems to be an order of magnitude faster. But the difference is much more striking with the debugger.
Implementation is at https://github.com/holoviz/colorcet/blob/main/colorcet/__init__.py. I also opened holoviz/colorcet#121.
cvzi commentedon Mar 15, 2024
Yes it was "solved" in emoji module by compressing the dict literal into a single line, previously the dict was spread over ~87k lines
cvzi commentedon May 17, 2024
FYI for anyone considering this solution, unfortunately compressing the dict into a single line has created a new problem for us, it causes
coverage reporton Python 3.12 to use excessive amounts of memory (in our case more than 20 GB).bersbersbers commentedon Jun 7, 2024
For the record, this issue (coveragepy/coveragepy#1785) should be gone with Python 3.12.4 thanks to python/cpython#119118, so the practicality of one-line workarounds should be improved. That is relevant since the original issue continues to exist in Python 3.12.4 (long runtime importing large dicts with debugger attached)
Denelbe commentedon Aug 29, 2024
I have a similar problem with module python-opcua.
The simple following script in vscode debugger runs in 2.7 seconds using Python 3.11.2 but 68 seconds with Python 3.12.5.
OS Linux (Debian 12)
VsCode 1.92.2
Python Debugger 2024.10.0
snmishra commentedon Aug 29, 2024
I've moved to pydevd. debugpy is unusable in Python 3.12, and I didn't want to go back to Python 3.11
rchiodo commentedon Aug 29, 2024
Debugpy actually uses pydevd under the covers, but hasn't yet updated to pydevd's latest which has support for 3.12.
laipz8200 commentedon Sep 2, 2024
I am currently debugging the repository langgenius/dify and am encountering a similar issue with the latest version, where the project takes an unusually long time to start (approximately 5 minutes) on my M1 Pro machine.
I would like to understand the underlying cause of this delay and request guidance on how to resolve it.
Environment Details:
Thank you for your assistance!
Feel free to let me know if you would like any additional information.
rchiodo commentedon Sep 3, 2024
Sorry there's nothing you can do. We need to finish moving to the new 3.12 sys.monitoring support.
rteitge commentedon Sep 9, 2024
Is there an approximate timetable for when we can start developing with vscode and devcontainer again? Since we are dependent on 3.12, vscode and devcontainer with the delays are unfortunately completely useless at the moment. That is not efficient working.
rchiodo commentedon Sep 9, 2024
All I can say is porting the Pydevd changes for 3.12 to debugpy are in progress. Can't say how long it will take though.
rchiodo commentedon Sep 9, 2024
This item:
#1640
rchiodo commentedon Sep 18, 2024
I'm pretty confident the pydev port will fix the performance issue.
Here's the difference for me between the two with the
colorcetexample:With sys.monitoring
With sys.trace
rchiodo commentedon Sep 23, 2024
Reopening, hasn't shipped yet.
Pull in pydevd sys.monitoring support (microsoft#1680)
rchiodo commentedon Sep 24, 2024
This issue should be fixed in the latest build of debugpy. It should ship with VS code in a future version of the Python Debugger Extension or you can install your own debugpy from pypi
bersbersbers commentedon Sep 25, 2024
Wow. 1.8.6 goes from 24s to 4s launching my app with debugger attached. Great work!
I see this has made its way into https://github.com/microsoft/vscode-python-debugger already via microsoft/vscode-python-debugger@afd0d2b.
Until that is released, this is how I was able to update the bundled
debugpyinvscode-python-debugger:fix(deps): update backend dependencies (patch) (patch)
Merge branch 'renovate/patch-backend-dependencies' into 'main'