Skip to content

Commit 14dda09

Browse files
authored
Merge pull request #28911 from timhoffm/mnt-lazyticklist
MNT: Fix double evaluation of _LazyTickList
2 parents cef6af6 + f1b0a28 commit 14dda09

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Axes creation speedup
2+
~~~~~~~~~~~~~~~~~~~~~
3+
4+
Creating an Axes is now 20-25% faster due to internal optimizations.

lib/matplotlib/axis.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -538,17 +538,19 @@ def __get__(self, instance, owner):
538538
# instance._get_tick() can itself try to access the majorTicks
539539
# attribute (e.g. in certain projection classes which override
540540
# e.g. get_xaxis_text1_transform). In order to avoid infinite
541-
# recursion, first set the majorTicks on the instance to an empty
542-
# list, then create the tick and append it.
541+
# recursion, first set the majorTicks on the instance temporarily
542+
# to an empty lis. Then create the tick; note that _get_tick()
543+
# may call reset_ticks(). Therefore, the final tick list is
544+
# created and assigned afterwards.
543545
if self._major:
544546
instance.majorTicks = []
545547
tick = instance._get_tick(major=True)
546-
instance.majorTicks.append(tick)
548+
instance.majorTicks = [tick]
547549
return instance.majorTicks
548550
else:
549551
instance.minorTicks = []
550552
tick = instance._get_tick(major=False)
551-
instance.minorTicks.append(tick)
553+
instance.minorTicks = [tick]
552554
return instance.minorTicks
553555

554556

0 commit comments

Comments
 (0)