Repository navigation
Conversation
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.
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.
|
Contributor
Author
|
Closing since clearly inferior in performance. |
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.
Description
This pull request is to propose alternative for: