pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: https://github.com/matplotlib/matplotlib/pull/31059

1abb27f2d0.css" /> PERF: Refactor bezier poly coefficient calcs for speedup by scottshambaugh · Pull Request #31059 · matplotlib/matplotlib · GitHub
Skip to content

PERF: Refactor bezier poly coefficient calcs for speedup#31059

Merged
QuLogic merged 2 commits into
matplotlib:mainfrom
scottshambaugh:bezier_coeffs
Feb 3, 2026
Merged

PERF: Refactor bezier poly coefficient calcs for speedup#31059
QuLogic merged 2 commits into
matplotlib:mainfrom
scottshambaugh:bezier_coeffs

Conversation

@scottshambaugh
Copy link
Copy Markdown
Contributor

@scottshambaugh scottshambaugh commented Feb 2, 2026

PR summary

Split off from #31005

This speeds up Path.get_extents which calls these bezier operations by caching more of the polynomial coefficient calculations. These repeated calcs were taking up about 25% of the get_extents call time, and are largely eliminated now.

Circled areas in the profiler screenshots below show this code path.

Before:
image

After:
image

Profiling test script:

import numpy as np
import matplotlib.pyplot as plt

fig, ax = plt.subplots()

n = 1000
rng = np.random.default_rng(42)
x = rng.random(n)
y = rng.random(n)
for i in range(n):
    ax.scatter(x[i], y[i])

fig.canvas.draw()
plt.close(fig)

PR checklist

@scottshambaugh scottshambaugh marked this pull request as ready for review February 2, 2026 18:57
Comment thread lib/matplotlib/bezier.py Outdated
Comment thread lib/matplotlib/bezier.py Outdated
@QuLogic QuLogic merged commit 9a41623 into matplotlib:main Feb 3, 2026
37 of 40 checks passed
@QuLogic QuLogic added this to the v3.11.0 milestone Feb 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy