fast_float
ryu
Our great sponsors
fast_float | ryu | |
---|---|---|
15 | 12 | |
1,267 | 1,131 | |
1.9% | - | |
8.8 | 5.9 | |
about 1 month ago | 2 months ago | |
C++ | C++ | |
Apache License 2.0 | Apache License 2.0 |
Stars - the number of stars that a project has on GitHub. Growth - month over month growth in stars.
Activity is a relative number indicating how actively a project is being developed. Recent commits have higher weight than older ones.
For example, an activity of 9.0 indicates that a project is amongst the top 10% of the most actively developed projects that we are tracking.
fast_float
-
Parquet: More than just “Turbo CSV”
> Google put in significant engineering effort into "Ryu", a parsing library for double-precision floating point numbers: https://github.com/ulfjack/ryu
It's not a parsing library, but a printing one, i.e., double -> string. https://github.com/fastfloat/fast_float is a parsing library, i.e., string -> double, not by Google though, but was indeed motivated by parsing JSON fast https://lemire.me/blog/2020/03/10/fast-float-parsing-in-prac...
-
What do number conversions (from string) cost?
For those that don't know, gcc 12.x updated its float parsing logic to something similar to fast_float and it's about 1/6 of the cost presented here (sub 100 in the graph presented here). Strongly suggest using that library or upgrading the compiler if you need the performance.
-
Can sanitizers find the two bugs I wrote in C++?
This makes sense for integers but betware floating point from_chars - libc++ still doesn't implement it and libstdc++ implements it by wrapping locale-dependent libc functions which involves temporarily changing the thread locale and possibly memory allocation to make the passed string 0-terminated. IMO libstdc++'s checkbox "solution" is worse than not implementing it at all - user's are better off using Lemire's API-compatible fast_float implementation [0].
-
Passing Programs To A Stack Machine
I'm a bit stuck on how to do the same thing in c++, due to containers only having a single type. The very inefficient way I'm currently doing it is by passing a program as a vector of strings, and then converting the string constants to doubles with the fast_float library.
-
Parsing can become accidentally quadratic because of sscanf
Just above this comment is a merged PR, which references fast_float library: https://github.com/fastfloat/fast_float
-
Making Rust Float Parsing Fast: libcore Edition
Daniel Lemire @lemire (creator of the algorithm, author of the C++ implementation, and provided constant feedback to help guide the PR).
-
RapidObj v0.1 - A fast, header-only, C++17 library for parsing Wavefront .obj files.
And out of 6,000 lines in the file, at least 3000 are other people's code: earcut for polygon triangulation and fast_float because .obj files typically contain a lot of floating point numbers so it's important to parse them quickly.
-
First release of dragonbox, a fast float-to-string conversion algorithm, is available
How this compares to https://github.com/fastfloat/fast_float ?
-
Why is std::from_chars<float> slow?
I tried to compare it against Daniel Lemire's excellent fast_float library. Fast float took about 180ms for the same program, and all I did was change "std" namespace prefix to "fast_float". It's a factor of 12 difference, at least my machine. I tried MSVC next, and it is a lot better, but it is still ~4 times slower than fast float. AFAIK, clang currently does not implement the feature at all.
-
Iterator invalidation of std::string_view
If you don't mind a 3rd party lib until your stdlib updates, https://github.com/fastfloat/fast_float is best-in-class.
ryu
-
Printing double aka the most difficult problem in computer sciences
Nah. This is about ryu printf.
-
Parquet: More than just “Turbo CSV”
> Google put in significant engineering effort into "Ryu", a parsing library for double-precision floating point numbers: https://github.com/ulfjack/ryu
It's not a parsing library, but a printing one, i.e., double -> string. https://github.com/fastfloat/fast_float is a parsing library, i.e., string -> double, not by Google though, but was indeed motivated by parsing JSON fast https://lemire.me/blog/2020/03/10/fast-float-parsing-in-prac...
- Faster way to convert double to string, not using "%f"?
-
After obtaning a CS degree and 16 years of experience in industry, I feel somewhat confident that I can answer your programming questions correctly. Ask me anything
Me and Ryu agree that the answer should be 0.30000000000000004
-
23 years into my career, I still love PHP and JavaScript
Apparently exact minimal float-to-string conversion is more recent than I thought, and many languages used to print more (Python?) or less (PHP) decimal digits than necessary to uniquely identify the bit pattern. Python correctly prints 46000.80 + 553.04 as 46553.840000000004, but I don't know if it ever prints more digits than needed. One recent algorithm for printing floats exactly is https://github.com/ulfjack/ryu, though I'm unaware what's the state-of-the-art (https://github.com/jk-jeon/dragonbox claims to be a benchmark and the best algorithm).
-
What's the most elegant algo in your subjective view and why?
On the huge speedup side, you have the Ryū algorithm for decimal conversion (Video, Source), which is now finding its way in most standard libraries. But it isn't a hack, and a very dense, complex and precise algo, nothing like the fast-and-loose inverse square root.
-
C++ devs at FAANG companies, what kind of work do you do?
Used a wizard's magic to print "3.14" faster
-
how to make ftoa procedure from scratch
Here's a paper that details an optimized algorithm (reference implementation). It also contains a description of a correct, but slow algorithm as well as references to classic papers on the subject. Earlier the classic implementation was the dtoa one included in netlib by David Gay.
-
Dragonbox 1.1.0 is released (a fast float-to-string conversion algorithm)
At the very core of all these theoretical stuffs, there is the theory of continued fractions. This is an immensely useful monster which I even dare call as the ultimate tool for floating-point formatting/parsing that everyone who wants to contribute in this field should learn. Before I learned continued fractions, my main tool for proving stuffs was the minmax Euclid algorithm (which is one of the greatest contributions of the wonderful Ryu paper), but it turns out that it is actually just a quite straightforward application of the theory of continued fractions. The main role minmax Euclid algorithm played was to estimate the maximum size of possible errors, but with continued fractions it is even possible to find the list of all examples that generate errors above a given threshold. This is something I desperately wanted but really couldn't do back in 2020.
-
FastDoubleParser: Java port of Daniel Lemires fast_double_parser
Ryū algorithm, the converse (doubles to strings), is also much faster than using Java's number formatting classes.
https://github.com/ulfjack/ryu/blob/master/src/main/java/inf...
What are some alternatives?
dragonbox - Reference implementation of Dragonbox in C++
rapidobj - A fast, header-only, C++17 library for parsing Wavefront .obj files.
C++ Format - A modern formatting library
concise-encoding - The secure data format for a modern world
fast-float-rust - Super-fast float parser in Rust (now part of Rust core)
jsoniter-scala - Scala macros for compile-time generation of safe and ultra-fast JSON codecs
RapidJSON - A fast JSON parser/generator for C++ with both SAX/DOM style API
itoa - Fast integer to ascii / integer to string conversion
simdutf8 - SIMD-accelerated UTF-8 validation for Rust.
oss-fuzz - OSS-Fuzz - continuous fuzzing for open source software.