in reply to Idea for new module/pragma
I've read that when working on programs where memory usage is important, it is best to avoid importing symbols from other packagesImporting stuff from modules isn't that expensive, and avoiding importing it won't save much. You see, the subs etc in the module, already exist in memory, as soon as the module is loaded. Even if you never call them, or even don't import them.
All that import does, is add a new name for the same sub in the symbol table for the current package. There is no recompilation, not even a copy of the sub body, for the new import!
n.b. The symbol table, or stash, is nothing but a plain hash containing globs, which are just binary structures with refs to various types of data sharing the same name — for example a reference to a sub body in the slot for the code ref.
So... I think you must misremember what you read. It is recommended not to import stuff from modules that you don't use, but not to save on memory, but in order to not to clutter the symbol table with useless stuff. Because every imported name restricts the choice you have for your own names of subs — thus: to prevent name clashes.
|
|---|