PERF: Skip kwargs normalization in Artist._cm_set#31000
PERF: Skip kwargs normalization in Artist._cm_set#31000timhoffm merged 5 commits intomatplotlib:mainfrom
Conversation
91ab3d8 to
340d63c
Compare
8cf7682 to
340d63c
Compare
340d63c to
be4aada
Compare
|
WRT #30979, since |
|
Looking at it again I think |
82d2d8c to
ef366a9
Compare
There was a problem hiding this comment.
Actually, for the specific case of text drawing, there's a much simpler solution: since #25346, the whole _cm_set() can be removed, because _get_layout() itself will use the wrapped text (this passes all test_text tests and the relevant wrapped text example, at least).
I am a bit dubious with the "check for equality" here because in theory property getters and setters can have all kinds of side effects (so eliding a get/set is not necessarily safe, even though it probably is in practice). (Not worth completely blocking the PR so feel free to ignore, but I don't really like it.)
On the other hand, unwrapping the end of the code (_internal_update tor reset the original values) as suggested by @QuLogic is probably a good idea (because at that point we know that all properties are indeed valid).
ef366a9 to
9a9722f
Compare
|
I'm on board with all of that @anntzer, updated. I'll move the text drawing change over to the other PR |
anntzer
left a comment
There was a problem hiding this comment.
Maybe update the docstring to add "(and skips the check for duplicate aliases, for optimization)".
|
Added |
Co-authored-by: Tim Hoffmann <[email protected]>
94250a3 to
17125fc
Compare
|
This should be squashed merged, it's a pretty messy commit history for what ended up being a very simple change. |
PR summary
_cm_setis called during everyText.draw()to handle text wrapping, but most text has wrapping disabled so_get_wrapped_text()returns the original text unchanged. The old code would always set and restore the value, but we can safely bypass that if the updated value is identical to the current.This bit of code was using 5.5% of total draw time in my benchmark script that renders an empty plot, now dropped down to 1%

PR checklist