Thread overview | |||||
---|---|---|---|---|---|
|
November 28, 2013 Does selective imports have an effect on the resulting executable? | ||||
---|---|---|---|---|
| ||||
Does selective imports have an effect on the resulting executable? For example if i included the following at the top of my source to only include one function from a library: import std.algorithm : reduce; Would it have any impact on the resulting executable? i.e. only include compiled code for the selected functions? If i imported the whole library like this: import std.algorithm; Is it more wasteful? Not as optimised? Any draw backs? Bigger executable? |
November 28, 2013 Re: Does selective imports have an effect on the resulting executable? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Gary Willoughby | On Thursday, 28 November 2013 at 12:31:11 UTC, Gary Willoughby wrote:
> Does selective imports have an effect on the resulting executable?
No, I don't think so. The compiler still reads the module and the linker still sees the whole object file to do its thing, it just doesn't bring all the names into scope.
|
November 28, 2013 Re: Does selective imports have an effect on the resulting executable? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Gary Willoughby | On Thursday, 28 November 2013 at 12:31:11 UTC, Gary Willoughby wrote:
> Does selective imports have an effect on the resulting executable? For example if i included the following at the top of my source to only include one function from a library:
>
> import std.algorithm : reduce;
>
> Would it have any impact on the resulting executable? i.e. only include compiled code for the selected functions?
>
> If i imported the whole library like this:
>
> import std.algorithm;
>
> Is it more wasteful? Not as optimised? Any draw backs? Bigger executable?
No, selective imports are just matter of namespace hygiene and code readability.
Scope-local imports , however, can impact resulting executable a lot if used inside templated scopes (nothing will be imported at all if it is not instantiated)
|
Copyright © 1999-2021 by the D Language Foundation