Open holmanb opened 1 week ago
Big +1 to changing to new-style named tuples with typing, but is there actually a runtime difference? They both will be evaluated at import time, correct?
Correct - I don't think that there will be much runtime difference - just the benefit of added typing.
It is not best practice, and it often adds unnecessary overhead.
Proposed Commit Message
Additional Context
The important part of this is regex compile - that can be done when/if the function is called rather than at import time which will save some cycles.
While
namedtuple()
andtuple()
aren't truly harmful, there are ways to define similar types statically rather than generating them at runtime, so I modified those in a few places too.Fixes https://github.com/canonical/cloud-init/issues/5344