From 12ec7401e8efdd3b2d1f2f8e2fe702ae62aac3e6 Mon Sep 17 00:00:00 2001 From: Andrey Date: Thu, 17 Sep 2026 14:14:11 +0000 Subject: [PATCH 1/2] erl: improve performance of `string.inspect` for floats Thank to ArcOnyx for initial implementation for `float.to_string`. Co-authored-by: ArcOnyx <11323309+arconyx@users.noreply.github.com> --- src/gleam_stdlib.erl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gleam_stdlib.erl b/src/gleam_stdlib.erl index 52b8f622..5169e555 100644 --- a/src/gleam_stdlib.erl +++ b/src/gleam_stdlib.erl @@ -285,7 +285,7 @@ inspect(Atom) when is_atom(Atom) -> inspect(Any) when is_integer(Any) -> erlang:integer_to_list(Any); inspect(Any) when is_float(Any) -> - io_lib_format:fwrite_g(Any); + erlang:float_to_binary(Any, [short]); inspect(Binary) when is_binary(Binary) -> case inspect_maybe_utf8_string(Binary, <<>>) of {ok, InspectedUtf8String} -> InspectedUtf8String; From e11a5f91b212d32cd3baa1c0fcf7901a0f4fa9ca Mon Sep 17 00:00:00 2001 From: Andrey Date: Thu, 17 Sep 2026 14:26:45 +0000 Subject: [PATCH 2/2] changelog entry --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 53f29d1a..74ab07fe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,8 @@ print NaN and Infinity. - The performance of the `to_string` function from the `float` module has been improved on the Erlang target. +- The performance of the `inspect` function from the `string` module for floats + has been improved on the Erlang target. ## v1.0.5 - 2026-08-06