Repository navigation
csv-core: make is_non_numeric cheaper - #442
Open
patrick-immometrica wants to merge 1 commit into
Open
patrick-immometrica wants to merge 1 commit into
patrick-immometrica wants to merge 1 commit into
Conversation
`QuoteStyle::NonNumeric` ran `parse::<f64>()` and then `parse::<i128>()` on every field, so text fields always paid for two failed parses. Plain integers are now detected with a byte scan, fields whose first byte can't start a number return early, and the `i128` parse is dropped since any input it accepts is also accepted by the `f64` parser. Writing the nfl and game benchmark data with `NonNumeric` drops from 1.60 ms to ~1.00 ms and from 6.24 ms to ~3.7 ms. I compared the old and new function on about a million generated inputs with no difference.
patrick-immometrica
marked this pull request as ready for review
November 14, 2026 11:12
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.
With
QuoteStyle::NonNumeric, every field goes throughparse::<f64>()and thenparse::<i128>(). Text fields fail both, so they pay for two parses each.Changes:
i128parse is gone, sincef64accepts every stringi128doesWriter benchmarks with
NonNumeric(time per iteration):For reference,
Necessaryis ~0.8 ms and ~2.3 ms on the same data.I checked the new function against the old one on about 1M generated inputs (signs, exponents, inf/nan spellings, junk) and got the same result for all of them. Also added a small unit test.