Closed toelli-msft closed 2 years ago
Can we move the call to inspect.getmembers
out of the loop? I'd suggest creating module_fns = dict(inspect.getmembers(module))
which simplifies the lookup later.
Oh, using a dict is a much better idea anyway! I'll do that instead.
Would it be OK to switch to this more direct style of finding the matching element? In the existing the logic is mixed up with the control flow which made it harder for me to understand.
Added: yield elements rather than manually collecting in a list. Unfortunately the only two options for turning the generator function into a reversed list that I know are
list(ksc_defs())[::-1]
andlist(reversed(list(ksc_defs())))
, both of which seem less clear than we might hope.