Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[Bug]: Python interpreter becomes slow at reading inputs after plotting with matplotlib #27515

Copy link
Copy link
Closed
@aradley

Description

@aradley
Issue body actions

Bug summary

I am experiencing an issue on two separate computers where after plotting with matplotlib the Python interpreter becomes very slow at reading new inputs. This is disruptive for coding and debugging.

I have provided a video below to show how the issue can be reproduced. This video was recorded on a new M3 Mac with a fresh install of Python and Visual Studio Code. The problem is reproducible outside of Visual Studio Code, i.e. when I run Python from the terminal, and I also experienced this issue on (slightly) older M2 mac.

screen-recording_2lZ84DeT.mp4

Python version: 3.9.6
Installed packages:
anndata 0.10.3
array-api-compat 1.4
cESFW 0.0.1
contourpy 1.2.0
cycler 0.12.1
dill 0.3.7
exceptiongroup 1.2.0
fonttools 4.46.0
h5py 3.10.0
importlib-resources 6.1.1
joblib 1.3.2
kiwisolver 1.4.5
llvmlite 0.41.1
matplotlib 3.8.2
multiprocess 0.70.14
natsort 8.4.0
numba 0.58.1
numpy 1.26.2
p-tqdm 1.4.0
packaging 23.2
pandas 2.1.4
pathos 0.3.1
Pillow 10.1.0
pip 23.3.1
plotly 5.18.0
ppft 1.7.6.7
pynndescent 0.5.11
pyparsing 3.1.1
python-dateutil 2.8.2
pytz 2023.3.post1
scikit-learn 1.3.2
scipy 1.11.4
seaborn 0.13.0
setuptools 69.0.2
six 1.16.0
tenacity 8.2.3
threadpoolctl 3.2.0
tqdm 4.66.1
tzdata 2023.3
umap-learn 0.5.5
wheel 0.42.0
zipp 3.17.0

Note that cESFW is one of my packages, which you can install from https://github.com/aradley/cESFW, but I would be very surprised if this was the issue as it uses basic Python packages.

Code for reproduction

import numpy as np
import matplotlib.pyplot as plt
import time

# Before plotting, reading and creating the below array is very fast.
start_1 = time.time()

Test_Array_1 = np.array(["An incredibly simple array that has lots of characters in it to show how slow VSCode starts to run after plotting something.",
                       "Blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah",
                       "Blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah",
                       "Blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah"])

end_1 = time.time()
print(end_1 - start_1)

# Create and show a simple plot
plt.plot(np.arange(10))
plt.show()

# Now if I create the same array as before, the python interpreter takes much longer to read the input.
start_2 = time.time()

Test_Array_2 = np.array(["An incredibly simple array that has lots of characters in it to show how slow VSCode starts to run after plotting something.",
                       "Blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah",
                       "Blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah",
                       "Blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah"])

end_2 = time.time()
print(end_2 - start_2)
# After plotting, the interpreter is magnitudes slower (ratio given by below calculation)
print((start_2 - end_2)/(start_1 - end_1))

Actual outcome

Outputs easily obtained from above code.

Expected outcome

Outputs easily obtained from above code.

Additional information

No response

Operating system

macOS 14.1.2 (23B2091)

Matplotlib Version

3.8.2

Matplotlib Backend

MacOSX

Python version

3.9.6

Jupyter version

No response

Installation

pip

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.