From: "watson1978 (Shizuo Fujita) via ruby-core" Date: 2026-08-12T13:34:59+00:00 Subject: [ruby-core:126376] [Ruby Feature#21308] Replacing the Float#to_s (dtoa.c) implementation with a modern algorithm Issue #21308 has been updated by watson1978 (Shizuo Fujita). Looks like we are about to get yet another vendored implementation of the same kind: https://github.com/ohler55/oj/pull/1095 proposes vendoring the same Boost-licensed fpconv (Grisu2) code that the json gem already ships. I think it is time to address this in Ruby itself rather than gem by gem. ---------------------------------------- Feature #21308: Replacing the Float#to_s (dtoa.c) implementation with a modern algorithm https://bugs.ruby-lang.org/issues/21308#change-118514 * Author: watson1978 (Shizuo Fujita) * Status: Open ---------------------------------------- This is a feature request to replace Ruby's `Float#to_s` implementation with a modern high-performance float-to-string conversion algorithm such as Grisu. Currently, `Float#to_s` in Ruby uses the BSD-derived implementation in [missing/dtoa.c](https://github.com/ruby/ruby/blob/master/missing/dtoa.c). Meanwhile, `json` gem has adopted a Grisu-based implementation in [ruby/json#768](https://github.com/ruby/json/pull/768), it has been improve the performance of float-to-string conversion dramatically. It appears to have brought about a 10 times improvement in performance. However, the improvement is limited to the `json` gem. If we can use the same implementation in `Float#to_s`, it will introduce the improvement in all float-to-string conversion cases. (In additional, it would be better if an API could be added that could be called directly from the C extension library, it will reduce the overhead of the call.) -- https://bugs.ruby-lang.org/ ______________________________________________ ruby-core mailing list -- ruby-core@ml.ruby-lang.org To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/