Faster floating point math with Rust's new API

Rust just made number-crunching faster, and the comments instantly turned into a math fight

TLDR: Rust 1.98 adds a new way to speed up decimal-number math while still letting developers limit where tiny rounding changes are allowed. Commenters immediately turned it into a debate over technical oversimplifications, with others using the news to dunk on Python’s missing speed tricks.

Rust’s latest update has developers buzzing because it finally gives programmers a stable way to tell the compiler, basically, “yes, you can be a little bolder here” when handling decimal numbers. The payoff? Code that can run much faster in some cases, especially when adding up huge piles of numbers. The catch, of course, is that speed comes with risk: tiny rounding differences can creep in. And that tiny caveat is exactly where the comment section smelled blood.

The biggest reaction wasn’t just “cool, faster!” It was people immediately nitpicking the article’s explanation like it was a live math courtroom drama. GeertB swooped in with a classic internet-engineer move: actually, even the supposedly simple integer example has a technical gray area around overflow, and the article glossed over it. Translation for normal humans: even the “easy” version may not be as clean-cut as advertised. Then rob74 jumped in with a totally different angle, pointing out that some languages treat number constants with extra precision, so the article’s “small number disappears” example felt suspiciously language-dependent. In other words, the comments became less “yay new feature” and more “your homework has red ink all over it.”

And because every programming thread eventually turns into a broader ecosystem complaint, pjmlp used the moment to lament that Python still doesn’t have the kind of smart built-in speed boost people dream about. That gave the whole discussion a fun side-quest energy: Rust fans celebrating, precision purists arguing, and Python folks staring wistfully into the distance. Peak developer drama.

Key Points

  • The article says Rust 1.98 introduces a stable API that allows more aggressive floating-point optimization with explicit developer control.
  • A benchmark summing one million `i64` values in Rust shows much faster performance than a similar benchmark summing one million `f64` values.
  • The integer benchmark is compiled with `RUSTFLAGS="-C target-cpu=x86-64-v3"` to enable code generation for modern x86-64 CPUs.
  • The article attributes the fast integer result to SIMD vectorization, including 256-bit instructions on the tested CPU.
  • The article explains that compilers are conservative with floating-point optimization because reordering floating-point operations can change numerical results due to rounding behavior.

Hottest takes

"a bit of a gray area that the article completely ignores" — GeertB
"the numbers used are constants, which are arbitrary precision in some languages" — rob74
"Ideally CPython would have a JIT ... but we are still not there yet" — pjmlp
Made with <3 by @siedrix and @shesho from CDMX. Powered by Forge&Hive.