PERF: Bezier root finding speedup#31005
Open
scottshambaugh wants to merge 3 commits intomatplotlib:mainfrom
Open
PERF: Bezier root finding speedup#31005scottshambaugh wants to merge 3 commits intomatplotlib:mainfrom
scottshambaugh wants to merge 3 commits intomatplotlib:mainfrom
Conversation
350fc98 to
3fdfa93
Compare
3fdfa93 to
95c8fcb
Compare
Member
|
Can you please split the two changes? I would like to review and discuss them separately. For the coefficient matrices, I'd like to have a built-in guarantee that the matrix and the formula yield the same result. This can be achieved in one of two ways:
|
1 task
95c8fcb to
af05432
Compare
Contributor
Author
timhoffm
reviewed
Feb 3, 2026
af05432 to
a9548a7
Compare
a9548a7 to
4206313
Compare
timhoffm
approved these changes
Feb 3, 2026
Member
|
Please fix the stubtest |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
PR summary
This speeds up
Path.get_extentswhich calls these bezier operations.Instead of
np.rootswhich does expensive eigenvalue decomposition, we can take advantage of the fact that we are only looking for roots on the limited [0, 1] interval and just do bisection for degree >= 3. Or we can calculate exactly for degree == 2. These both end up being much faster.This code section is circled below in the profiler runs.
Before:

After:

Profiling test script:
PR checklist