try to avoid functions/makers as (default) arguments
We are writing dataflow as:
@configurable
def make_velout_tracks(make_tracks = make_velo_tracks, ...):
velo_tracks = make_tracks()
return VeloUTTracking(velo_tracks, ...).OutputTracks
The reason that we give data makers as function defaults is that one is then able to control the behaviour of this function with bind before it is actually executed in the function body.
If we would give the data directly as function default, like
@configurable
def make_velout_tracks(velo_tracks = make_velo_tracks(), ...):
return VeloUTTracking(velo_tracks, ...).OutputTracks
make_velo_tracks
would be evaluated before any bind, since default arguments in python are evaluated as soon as the function definition appears, which is when you define or import it. This is too early if we want to change any default argument via bind beforehand.
However, the second, not working example looks much more intuitive. We might be able to make it work, question is if this is a good idea.
We will have to trigger reevaluation of default arguments every time a function is called if there is a bound @configurable
down the chain. I am not sure whether we are easily able to check this, so we would probably just go with reevaluating every argument every time.
This impacts the performance, but maybe together with #52 (closed) it doesn't blow up too much.
Also this increases python startup time since we probably cannot avoid that the default arguments are being evaluated at import/definition time even though we might never use the result.
Note that going down this road also means that we loose a (questionable) feature of python:
def fun(arg=[]):
arg.append(1)
return arg
fun() # -> [1]
fun() # -> [1,1]
fun() # -> [1,1,1]