Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4e76477

Browse files
PERF: Skip kwargs normalization in Artist._cm_set (#31000)
--------- Co-authored-by: Scott Shambaugh <[email protected]> Co-authored-by: Tim Hoffmann <[email protected]>
1 parent e3776e9 commit 4e76477

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

lib/matplotlib/artist.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1292,14 +1292,17 @@ def set(self, **kwargs):
12921292
@contextlib.contextmanager
12931293
def _cm_set(self, **kwargs):
12941294
"""
1295-
`.Artist.set` context-manager that restores original values at exit.
1295+
A context manager to temporarily set artist properties.
1296+
1297+
In contrast to `.Artist.set` and for performance, this skips the
1298+
`normalize_kwargs` check.
12961299
"""
12971300
orig_vals = {k: getattr(self, f"get_{k}")() for k in kwargs}
12981301
try:
1299-
self.set(**kwargs)
1302+
self._internal_update({k: kwargs[k] for k in orig_vals})
13001303
yield
13011304
finally:
1302-
self.set(**orig_vals)
1305+
self._internal_update(orig_vals)
13031306

13041307
def findobj(self, match=None, include_self=True):
13051308
"""

0 commit comments

Comments
 (0)