float_fast_print 0.1.0

Fast float-to-string conversion based on the Ryū algorithm by Ulf Adams.
Documentation

Overview

A Rust version of the Ryū float-to-string conversion algorithm by Ulf Adams of Google Germany.

Description

The purpose of this crate is to improve the speed of converting f32 and f64 to string representations, which is particularly important when performing high-performance serialisation of JSON, CSV, XLSX, and scientific data formats where all numbers are internally treated as floating point. In some cases, this can be the bottleneck to serialisation.

During development of this code it was noted that the serde_json crate references the dtoa crate, which is both slower and contains unsafe code. This crate uses no unsafe code, and could potentially use #![no_std] as well.

Status

This crate is currently very much in the work-in-progress state, and is not yet usable. However, things are looking promising, with the Ryū bench_write_f32_shortest function absolutely smoking the currently available alternatives:

test tests::bench_dtoa               ... bench:          45 ns/iter (+/- 1)
test tests::bench_f32_debug          ... bench:         108 ns/iter (+/- 0)
test tests::bench_f32_format         ... bench:         109 ns/iter (+/- 0)
test tests::bench_write_f32_shortest ... bench:          25 ns/iter (+/- 0)

References