Teju Jaguá – Blazing fast algorithm for printing floats

⚓ Rust    📅 2025-06-02    👤 surdeus    👁️ 2      

surdeus

Warning

This post was published 70 days ago. The information described in this article may have changed.

teju is a Rust implementation of the (novel) Tejú Jaguá algorithm for converting binary floats into a decimal representation. It exposes an interface that is drop-in compatible with the very popular ryu crate used for the same purpose.

assert_eq!(teju::Buffer::new().format(1.234), "1.234")

Like ryu, it is substantially faster than going through the standard library formatting facilities.
Compared to ryu, it should be even faster (slightly faster, or 5 or 6 times faster, depending on the inputs), and it also exposes more flexible formatting options (e.g. always in scientific notation, or never like in std).

Microbenchmarks comparing teju, ryu and std are included in the readme but please take those with a grain of salt [1]. They can be run with cargo bench.

Teju is feature complete and includes extensive tests, but it's still a work in progress (more formatting options, cleaner code, more profiling+tuning the low-level implementation, etc).

[1] For example, both teju and ryu use lookup tables, so a tight benchmark loop where these are always hot in cache may not be representative of your workload.

1 post - 1 participant

Read full topic

🏷️ rust_feed