Skip to content

Instantly share code, notes, and snippets.

@mkroutikov
Created July 12, 2017 11:31
Show Gist options
  • Save mkroutikov/176f24ed2ced4129c1618a9f21af1f5d to your computer and use it in GitHub Desktop.
Save mkroutikov/176f24ed2ced4129c1618a9f21af1f5d to your computer and use it in GitHub Desktop.
Lazy-loading domain map
class DomainMap:
_domain_map = None
@classmethod
def _get(cls):
# do heavy lifting here
# result = ...
return result
@classmethod
def get(cls):
if cls._domain_map is None:
cls._domain_map = cls._get()
return cls._domain_map
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment