Skip to content

Commit a532bf1

Browse files
committed
Avoid extra copy initializing empty Affine2D
This saves a small amount of time each: ``` In [1]: from matplotlib.transforms import Affine2D In [2]: %timeit Affine2D() 1.42 µs ± 6.17 ns per loop (mean ± std. dev. of 7 runs, 1,000,000 loops each) ``` vs ``` In [1]: from matplotlib.transforms import Affine2D In [2]: %timeit Affine2D() 1.1 µs ± 13 ns per loop (mean ± std. dev. of 7 runs, 1,000,000 loops each) In [3]: 1.1/1.42 Out[3]: 0.7746478873239437 ```
1 parent bcfd5e6 commit a532bf1

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lib/matplotlib/transforms.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1890,7 +1890,7 @@ def __init__(self, matrix=None, **kwargs):
18901890
super().__init__(**kwargs)
18911891
if matrix is None:
18921892
# A bit faster than np.identity(3).
1893-
matrix = IdentityTransform._mtx.copy()
1893+
matrix = IdentityTransform._mtx
18941894
self._mtx = matrix.copy()
18951895
self._invalid = 0
18961896

0 commit comments

Comments
 (0)