Skip to content

Conversation

@ndren
Copy link

@ndren ndren commented Nov 14, 2025

This PR special cases base 10 integer parsing to speed it up using the Rust stdlib.

Some code I used to test (run locally, I don't have a wasm build)

N ← 1e6
⊃($LongNumsFill ⊙◌⍜now⋕₁₀ ⬚@0 °⋕ ⇡ N
| $LongNumsBoxed ⊙◌⍜now⋕₁₀ °⋕ ⇡ N
| $ShortNumsFill ⊙◌⍜now⋕₁₀ ⬚@0 °⋕ ▽ (÷10 N) ⇡ 10
| $ShortNumsBox ⊙◌⍜now⋕₁₀ °⋕ ▽ (÷10 N) ⇡ 10
)
Metric main PR Speedup (%)
LongNumsFill 0.494306 0.355260 28.13%
LongNumsBoxed 0.626325 0.479558 23.43%
ShortNumsFill 0.351373 0.316105 10.04%
ShortNumsBox 0.493949 0.447104 9.48%

Note this code parses f64 more accurately than the code that was previously in use, so for some edge cases it would behave differently by a few ULP. Is that acceptable? (What's nice about this is that it now matches the results of using a float literal, since it now rounds correctly)

Example:

⋕₁₀ "3.14159265358979285"
# Before: π
# After: ~π

@kaikalii
Copy link
Member

Specifying π and co to the maximum precision should parse to π.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants