Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This address some of #4767.
The issue in 604299f is that
np.MachAr(float).xmin
takes ~8-10 ms and gets 2x in thehitlist
code path. Moving this to a constant at the top is a major speed up and for a blank figure gets the hitlist run time down to 5-6ms from a bit over 20ms (on the computer I was testing on).There is still an issue that sorting out if the cursor hits a
Line2D
artist takes at least 1ms so if you have 300 lines, it takes a third of a second for the callback to run.Long term, we should look into making this code faster by making contains run faster (a lot of time is spent in https://github.com/matplotlib/matplotlib/blob/master/lib/matplotlib/lines.py#L36), by finding a way to cache this in a smart way but in the short term I think we need to add a per-axes way of turning this off and probably default to off.
attn @blink1073 @mdboom @pwuertz