I am trying to understand how passing function outputs between modules work and I would like to know if my reasoning is correct.
Let’s assume we have the following modules:
a = [1,2,3]
b = x.+1
aux = M1.foo()
c = bar(aux)
c = bar(M1.foo())
Does this mean that “aux” (which is global variable in M2) will impact performance of function “bar” in approach # 1.?
What if we use approach # 2. ?
No. The use of global variable will affect the code that uses it. So the performance of
bar(aux) will be affected but the performance of the code in
I believe there will be a small performance impact when using
aux since it’s global and Julia needs to verify the type before passing it to bar. But that should be it. When passing the value directly without using a global variable Julia is able to verify the type returned from foo and pass it to bar when the code is compiled.
Now it’s clear. Thank you all for your help!