Why can't we use Go way to use fast algorithm where round off won't be required and keep the slow correct algorithm for the one where round off will be required.

As I am experimenting with Rust, I noticed it's string to float method is considerably slower than hand written code. Golang string to float is also faster than Rust's. Why can't we use Go way to use fast algorithm where round off won't be required and keep the slow correct algorithm for the one where round off will be required.
You already invited:

fidel

Upvotes from:

First thing, are you running a release build? If so and you've got a faster (correct) implentation, you can of course open a merge request on the standard library. Or, even if you have a way that should be faster, but haven't written it yet, you can open an issue there describing it.

However, if you'd need to change the API (eg. offering two parsing methods instead of one), then that would need to go through the full RFC process (and changing behaviour of the current one would probably not be accepted, things are supposed to stay compatible).

Anyway, in general, if there's a balancing between correctness and speed, Rust first tries to do both and if that fails, prefers correctness in the place where people are going to reach for the thing first (and maybe offer alternatives as additional methods or something).

If you wanna answer this question please Login or Register