Given a dictionary that is consistently referred to :
def getMyDict():
myDict = {};
myDict['1'] = '1'
return myDict
To access a dictionary value I use :
getMyDict()['1']
How to design dictionary so that the creation of the dictionary is just evaluated once. So that multiple calls to getMyDict['1']
do not result in multiple calls to myDict['1'] = '1'
Coming from Scala this can be accomplished using lazy keyword : What does a lazy val do?
This functionality does not appear to exist in Python as is ?
Closest i found is : Python lazy evaluator
The above dictionary example is not real world, but contrived to illustrate the point.