Title: Introduce _TickGroup facade for collective tick operations by timhoffm · Pull Request #32623 · matplotlib/matplotlib · GitHub
Open Graph Title: Introduce _TickGroup facade for collective tick operations by timhoffm · Pull Request #32623 · matplotlib/matplotlib
X Title: Introduce _TickGroup facade for collective tick operations by timhoffm · Pull Request #32623 · matplotlib/matplotlib
Description: PR summary Per #5665, tick management is a substantial cost factor with the potential for large performance gains. Changes are complicated because (1) many details of the ticks are publically exposed and (2) tick management is complicated and scattered thoughout axis.py - i.e. we already try to lazily instantiate, copy some state etc. In #5665 (comment) I outlined a way how we can get out of this mess. This PR implements steps create a fascade _TickGroup around the ticks and provide operations to work on all ticks at once and Replace all internal loops over ticks by these aggregate functions. While the code change looks substantial, it's actually a pure straight forward refactoring: I have merely moved the code snippets that mess with ticks into dedicated function grouped under the facade _TickGroup; you'll find most sippets moved almost 1:1. _TickGroup does not own tick-related state (yet). Tick storage stays in majorTicks/minorTicks. Some notable properties: Subclass hooks (get_major_ticks/get_minor_ticks, _get_tick, _copy_tick_props) still work. Speed is unchanged. Left out on purpose: the draw/layout path (_update_ticks returning ticks_to_draw, _get_ticklabel_bboxes, the draw loop). Spines, mplot3d and axisartist use that tick list, so it belongs to the representation switch (step 3). The first commit adds only tests on previously uncovered code paths: They pass on the unchanged code. - These tests are Claude-suggested. I'm only +0.2 on adding them. They are at the border of being too excessive, but I left them because they reasonably increase coverage, which may be a good thing if we want to do larger refactorings. Why is this reaonable / what's next? With all tick operations aggregated in TickGroup I plan to investigate optimization potentials (step 3+4 in #5665 (comment)). What exactly is still to be seen, could e.g. be collections, or "lightweight" Artists with shared properties or just lazily created Artists (each tick consists of 3 Line2D and 2 Text objects and a substantial part of them is often unused). But even if we don't optimize, this refactoring is already a win. The tick management responsibility was spread throughout the whole Axis class (and even beyond - see the backend_bases change here). Collecting them in one class and giving the operations clear names substantially improves architecture and ability to reason about the code. AI Disclosure Claude Code (Claude Opus 5.5) was used to profile tick creation, to look through the existing per-tick code paths, and to draft the _TickGroup implementation and the new tests, based on the design I outlined in #5665. I reviewed and adjusted the code. PR quality check Use an expressive title, e.g. "Fix title font property precedence" New and changed code is tested [N/A] Plotting related features are demonstrated in an example [N/A] New features and API changes have release notes Documentation complies with general and docstring guidelines
Open Graph Description: PR summary Per #5665, tick management is a substantial cost factor with the potential for large performance gains. Changes are complicated because (1) many details of the ticks are publically exp...
X Description: PR summary Per #5665, tick management is a substantial cost factor with the potential for large performance gains. Changes are complicated because (1) many details of the ticks are publically exp...
Opengraph URL: https://github.com/matplotlib/matplotlib/pull/32623
X: @github
Domain: github.com
IPv4 address: 140.82.114.3
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:dd9bfeb8-a7f2-41be-dda7-76f51910bdad |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | 813A:2BB917:10C99DD:172D5FC:6B06B3E3 |
| html-safe-nonce | ace9cf2968ab47b779e9cb7f199b567c1d1a8b560de8eb643eea5259846315a5 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4MTNBOjJCQjkxNzoxMEM5OUREOjE3MkQ1RkM6NkIwNkIzRTMiLCJ2aXNpdG9yX2lkIjoiODY0Mjg3MTY5NzgwNjM3Mzg1OSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | cf436b69cd4a971d90ea4cc95e4f14e5f67c2ed577f0ea887a2688643f3a288f |
| hovercard-subject-tag | pull_request:5386283571 |
| 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/32623/files |
| twitter:image | https://avatars.githubusercontent.com/u/2836374?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/2836374?s=400&v=4 |
| og:image:alt | PR summary Per #5665, tick management is a substantial cost factor with the potential for large performance gains. Changes are complicated because (1) many details of the ticks are publically exp... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 9b2b1f32e21f9e529372294897d423fa443a20a3a37bafa95dec0f213469ebfc |
| 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 | 5402de66059e5821fab003de929c7056c92d863f |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | no-cache |
Viewport: width=device-width