Closed Bug 1009252 Opened 12 years ago Closed 8 years ago

implement python 3.2's @functools.lru_cache in mozharness

Categories

(Release Engineering :: Applications: MozharnessCore, defect)

defect
Not set
normal

Tracking

(Not tracked)

RESOLVED INCOMPLETE

People

(Reporter: mozilla, Unassigned)

References

()

Details

(Whiteboard: [mozharness])

::: scripts/merge_day/b2g_tag.py @@ +98,5 @@ > + By default everything in self.config['b2g_branches'], > + but we can override that list with --gecko-repos. > + """ > + if self.gecko_repos: > + return self.gecko_repos Just a random idea, not related to the current review. I see this pattern (if self.prop: return prop) almost everywhere in mozharness. We could use @property and use (or implement) LRU cache (like in https://docs.python.org/3/library/functools.html#functools.lru_cache) to get rid of the boilerplate and make the code more readable. Something like this: @property @lru_cache() def gecko_repos(self): gecko_repos = self.config.get("gecko_repos", self.config['b2g_branches'].keys()) gecko_repos.sort() return gecko_repos And later in the code reference as self.gecko_repos.
Summary: implement python 3.2's @functools.lru_cache in mozharness as @property → implement python 3.2's @functools.lru_cache in mozharness
Component: General Automation → Mozharness
Status: NEW → RESOLVED
Closed: 8 years ago
Resolution: --- → INCOMPLETE
You need to log in before you can comment on or make changes to this bug.