Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I agree with some of this, and the author could've made a better case for from/to_chars:

- Afaik stoi and friends depend on the locale, so it's not hard to believe this introduced additional overhead. The implicit locale dependency is also often very surprising.

- std::stoi only accepts std::string as input, so you're forced to allocate a string to use it. std::from_chars does not.

- from/to_chars don't throw. As far as I know this won't affect performance if it doesn't happen, it does mean you can use these functions in environments where exceptions are disabled.



Locale env stuff is inherently thread unsafe, which is the main reason to never rely on it.


There's also the new Ryu algorithm that is being used, which is probably the biggest speed up.

https://github.com/ulfjack/ryu


AFAIK the state of the art now is "dragonbox":

https://github.com/jk-jeon/dragonbox




Consider applying for YC's Winter 2026 batch! Applications are open till Nov 10

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: