3 ms·
Modules don’t import everything. In Python, import is an act of bringing in everything into the namespace (under its own or otherwise). In compiled languages,
by dagmx 3y ago
Modules don’t import everything.
In Python, import is an act of bringing in everything into the namespace (under its own or otherwise).
In compiled languages, it is the act of making it available within this compilation unit. Things that are unused are stripped out and only what you either use or re-export have an effect. That is of course for static binaries, for dynamic linkage none of it really matters.
In fact modules can be more efficient than headers, because the way C/C++ work is that everything within the header file is verbatim copied into the file referencing it. This isn’t true with modules.