Title: PERF: Speed up add_patch by scottshambaugh · Pull Request #32026 · matplotlib/matplotlib · GitHub
Open Graph Title: PERF: Speed up add_patch by scottshambaugh · Pull Request #32026 · matplotlib/matplotlib
X Title: PERF: Speed up add_patch by scottshambaugh · Pull Request #32026 · matplotlib/matplotlib
Description: PR summary add_patch is currently very slow since it does bezier checks on all lines, but we can fast-path this for the common straight line case. In the below test script, add_patch dropped from 139 seconds to 50 milliseconds (~2700x improvement). import numpy as np import matplotlib.pyplot as plt from matplotlib.path import Path from matplotlib.patches import PathPatch np.random.seed(0) n = 100000 verts = np.random.rand(n, 2) codes = np.full(n, Path.LINETO, dtype=np.uint8) codes[0] = Path.MOVETO p = Path(verts, codes) fig, ax = plt.subplots() for _ in range(10): ax.add_patch(PathPatch(p)) plt.close(fig) AI Disclosure Manually identified, claude suggested edits, manually reviewed / edited. PR checklist [n/a] "closes #0000" is in the body of the PR description to link the related issue new and changed code is tested [n/a] Plotting related features are demonstrated in an example [n/a] New Features and API Changes are noted with a directive and release note Documentation complies with general and docstring guidelines
Open Graph Description: PR summary add_patch is currently very slow since it does bezier checks on all lines, but we can fast-path this for the common straight line case. In the below test script, add_patch dropped from 1...
X Description: PR summary add_patch is currently very slow since it does bezier checks on all lines, but we can fast-path this for the common straight line case. In the below test script, add_patch dropped from 1...
Opengraph URL: https://github.com/matplotlib/matplotlib/pull/32026
X: @github
Domain: github.com
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:e7c78593-af45-8af4-a0b6-811db6a955aa |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | E788:234B42:29064AC:38002DD:6A5446A8 |
| html-safe-nonce | 9b7244e41b2b7897cdb41e06afc45a4b99b5d4f488b0b06ebeb344945ea66371 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFNzg4OjIzNEI0MjoyOTA2NEFDOjM4MDAyREQ6NkE1NDQ2QTgiLCJ2aXNpdG9yX2lkIjoiMzk2MzQ4OTI0MjM2NjM2MzMwNCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 1f743398aa6639db8d1040997bef7ca345114bd67c16d3f49656da130664b4f4 |
| hovercard-subject-tag | pull_request:4025349406 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/matplotlib/matplotlib/pull/32026/files |
| twitter:image | https://avatars.githubusercontent.com/u/14363975?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/14363975?s=400&v=4 |
| og:image:alt | PR summary add_patch is currently very slow since it does bezier checks on all lines, but we can fast-path this for the common straight line case. In the below test script, add_patch dropped from 1... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | b9a586c06a05a7a86fc7e3f4dbd03e42f6869085879aa184aa6369456dbd50fb |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/matplotlib/matplotlib git https://github.com/matplotlib/matplotlib.git |
| octolytics-dimension-user_id | 215947 |
| octolytics-dimension-user_login | matplotlib |
| octolytics-dimension-repository_id | 1385122 |
| octolytics-dimension-repository_nwo | matplotlib/matplotlib |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 1385122 |
| octolytics-dimension-repository_network_root_nwo | matplotlib/matplotlib |
| turbo-body-classes | logged-out env-production page-responsive full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 07a982c1d40157c619b364352b704c3ce66bb332 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width