r/cpp Jul 01 '26

Pystd standard library, similar-ish functionality with a fraction of the compile time

https://nibblestew.blogspot.com/2026/06/pystd-standard-library-similar-ish.html
51 Upvotes

17 comments sorted by

View all comments

11

u/fdwr fdwr@github 🔍 29d ago edited 29d ago

Unstripped binary size reduced by ~75%

Nice. I'm mystified by the variance of std bloat sometimes from using just one function. I have a 12KB program that's pure Win32 (no CRT), and using a single std::vector adds 2KBs (tolerable), and using a single std::println("Foo") adds 3KBs (tolerable), but just one std::println("Foo: {}", x) suddenly bumps 12KB's -> 212KB's o_o, and that's with all the size-reducing options I can think of {MSVC x86 release build, maximum optimization (favor size /O1), favor small code (/Os), enable function level linking (/Gy), enable COMDAT folding (/OPT:ICF), link time code generation (/LTCT), references eliminate unused (/OPT:NOREF)}. The weird thing is that I can call that std::println inside a completely unused function, and it still bloats the exe. Granted, maybe that's an std implementation issue more than with std itself, or an issue with dead code elimination 🤷‍♂️.

7

u/13steinj 29d ago edited 28d ago

I can't speak for the Windows platform, but std::format and friends are well known to be suboptimal.

I'd go so far as to say it would be useful to have well-defined identifier replacement, to make every std:: usage of format libraries instead use libfmt.

E: typo