8000 PRF: only do expensive things once · matplotlib/matplotlib@2d0cc7d · GitHub
[go: up one dir, main page]

Skip to content

Commit 2d0cc7d

Browse files
committed
PRF: only do expensive things once
Looking up MachAr was taking about 10ms which is way to slow to be inside of the mouse motion 8000 event loop. We are using it to get a constant so we can look it up and compute the constant once at the top.
1 parent ed44362 commit 2d0cc7d

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

lib/matplotlib/transforms.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@
5050
from .path import Path
5151

5252
DEBUG = False
53-
53+
# we need this later, but this is very expensive to set up
54+
MINFLOAT = np.MachAr(float).xmin
5455
MaskedArray = ma.MaskedArray
5556

5657

@@ -2738,7 +2739,7 @@ def nonsingular(vmin, vmax, expander=0.001, tiny=1e-15, increasing=True):
27382739
swapped = True
27392740

27402741
maxabsvalue = max(abs(vmin), abs(vmax))
2741-
if maxabsvalue < (1e6 / tiny) * np.MachAr(float).xmin:
2742+
if maxabsvalue < (1e6 / tiny) * MINFLOAT:
27422743
vmin = -expander
27432744
vmax = expander
27442745

0 commit comments

Comments
 (0)
0