r/cpp • u/llort_lemmort • 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
50
Upvotes
View all comments
Show parent comment
0
u/13steinj Jul 02 '26 edited Jul 02 '26
Less than a minute is fast. You can debate with people about how "that's subjective" until the cows come home, but people have commonly complained about 10+ minute build times on this subreddit. Some have expressed 2 hours. Some have even expressed multi-day build times.
If you just had more code, your "approximately linear" assumption breaks down very quickly. If you have approximately the same amount of code in a different manner (I deal with single TUs that are 10 minutes and low-dependency, as I've mentioned in the other thread), it breaks down even quicker.
When the above (multi hour, multi-day build times, multi-minute single-TU times) is included in your distribution, you stop caring very quickly about anyone who claims they've sped up their build by double-digit percentages... from less than a minute to lesser than a minute.
E: also, while -j 1 is a nice goal, the long compile times I am mentioning elsewhere in this comment are -j 24+. To get a sense of just how bad the distribution is. If every TU includes the stdlib, sure, you'll be linear, to how many TUs you have.
I mean, that depends on what you call "boring." I had what I would call a bunch of boring log/assert-statement-like code. I reduced build-times by double-digit percentages on multi-minute TUs, and there, I am happy to use percentages, because the way I did it is guaranteed to be linear. I swapped out the tuple implementation for that within Boost.Hana in a key area, and the std::function implementation for one that didn't use std::tuple under the hood to pass arguments around.
Over 30% saved, std::function and std::tuple were still in-use in the TUs, their headers still included-- and now more headers and code included too, but more efficient template instantiations.
Using lines of code as your negative-correlation analog for compile time is about as useful as using it as your positive-correlation metric for developer productivity.
When doing so about lines of code, your speedup is fundamentally a constant (though, you can consider it a multiplier / percentage to a point for unique template instantiations). Including
<vector>is a constant amount of time, related to the lines of code therein. Instantiating it is linear, to the amount ofstd::vectorcode (not everything else that supports it that isn't templated) x the number of unique instantiations.Realistically it's unachievable no matter what standard library you use, unless you cut corners and make these things work for far fewer cases than they currently do. But what people end up realizing as they do this, is that when everyone has their own snowflake vector implementation to compile, and you have to write translation code to match, you end up increasing compile times, not decreasing them.