Improve Line2D and MarkerStyle instantiation#6694
Improve Line2D and MarkerStyle instantiation#6694tacaswell merged 4 commits intomatplotlib:masterfrom
Conversation
lib/matplotlib/markers.py
Outdated
| self._fillstyle = fillstyle | ||
| self._recache() | ||
| # do not call _recache() if marker is not yet set up | ||
| if self._marker is not None: |
There was a problem hiding this comment.
I do not like this much. Otherwise we can extract body of set_fillstyle without _recache() call to an internal method and call it from __init__ and set_fillstyle.
There was a problem hiding this comment.
Maybe add a _defer_recache=False kwarg to both set_marker and set_fillstyle? That way in __init__ you can prevent it from running.
A more invasive (but maybe better?) solution could be to use the stale/invalid pattern and then in all of the get_* methods check if it is stale and if so recache it.
Because `set_marker` calls it by itself
lib/matplotlib/markers.py
Outdated
| # The _recache() is called in both set_fillstyle() and set_marker() | ||
| # methods that's why here we have to have either marker or fillstyle | ||
| # preinitialized before setting other. | ||
| self._marker = None |
There was a problem hiding this comment.
It is probably better from a readability stand point to initialize all of the state here, rather than relying on a call to _recache to set it all up.
1ba7be6 to
486ce4d
Compare
|
I have pushed alternative solution for double What about moving out initialization from |
|
I suspect that not all of the |
|
Yes, I can confirm this as I have already tried it. |
This reduces
MarkerStyle._recache()calls from 4 to 1 inLine2Dinstantiation