Skip to content

Slight alternative to gh-19942 - DO NOT MERGE - #19998

Closed
mhvk wants to merge 12 commits into
astropy:mainfrom
mhvk:pr-19942
Closed

mhvk wants to merge 12 commits into
astropy:mainfrom
mhvk:pr-19942

Conversation

@mhvk

@mhvk mhvk commented Jun 29, 2026 •

Copy link
Copy Markdown
Contributor

Description

This pull request is to propose alternative for:

  • By checking this box, the PR author has requested that maintainers do NOT use the "Squash and Merge" button. Maintainers should respect this when possible; however, the final decision is at the discretion of the maintainer that merges the PR.

veyron-kairo and others added 12 commits June 25, 2026 11:40
The .value property formatted each time with str.format in a Python loop,
which dominated the runtime (the ERFA call doing the real work is a tiny
fraction of it). Build the output with array operations instead: write the
digits of each component into a single code-point buffer and view the rows
as fixed-width strings. This is well over ten times faster for large arrays.

The output stays byte-for-byte identical. Layouts that aren't a fixed-width
run of integer fields fall back to the old per-element path, e.g. years that
span different numbers of digits within a single array.
Compare the fast output to the original loop (disabled via monkeypatch) over
several formats, precisions and a masked value, and check that mixed-width
years fall back correctly.
_write_decimal always zero-pads, so a fixed-width spec without the "0" flag
(which str.format pads with spaces) would come out wrong. Restrict the
vectorized path to zero-padded or bare integer fields and leave anything else
to the per-element loop. No built-in subformat is affected; this just guards
custom format strings.
towncrier checks that fragment numbers correspond to the PR, so this is 19942
rather than the issue number.
Use the phrasing suggested in review.
Cover the instant just after a leap day, and a few non-default out_subfmt
values including ones that drop the seconds field.
Add cases for a template with a trailing literal, an unrecognized field
name that bails out of the fast path, and the signed branch of the
decimal writer, so the new vectorized code is fully exercised.
@github-actions

Copy link
Copy Markdown
Contributor

Thank you for your contribution to Astropy! 🌌 This checklist is meant to remind the package maintainers who will review this pull request of some common things to look for.

  • Do the proposed changes actually accomplish desired goals?
  • Do the proposed changes follow the Astropy coding guidelines?
  • Are tests added/updated as required? If so, do they follow the Astropy testing guidelines?
  • Are docs added/updated as required? If so, do they follow the Astropy documentation guidelines?
  • Is rebase and/or squash necessary? If so, please provide the author with appropriate instructions. Also see instructions for rebase and squash.
  • Did the CI pass? If no, are the failures related? If you need to run daily and weekly cron jobs as part of the PR, please apply the "Extra CI" label. Codestyle issues can be fixed by the bot.
  • Is a change log needed? If yes, did the change log check pass? If no, add the "no-changelog-entry-needed" label. If this is a manual backport, use the "skip-changelog-checks" label unless special changelog handling is necessary.
  • Is this a big PR that makes a "What's new?" entry worthwhile and if so, is (1) a "what's new" entry included in this PR and (2) the "whatsnew-needed" label applied?
  • At the time of adding the milestone, if the milestone set requires a backport to release branch(es), apply the appropriate "backport-X.Y.x" label(s) before merge.

@github-actions github-actions Bot added the Docs label Jun 29, 2026
@pllim pllim added this to the v8.1.0 milestone Jun 29, 2026
@mhvk

mhvk commented Jun 30, 2026

Copy link
Copy Markdown
Contributor Author

Closing since clearly inferior in performance.

@mhvk mhvk closed this Jun 30, 2026
@mhvk
mhvk deleted the pr-19942 branch August 24, 2026 14:00
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.

4 participants