#NEWLINE# def memoize( analyzer ) : #NEWLINE# #INDENT# _cache = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# def memoized( fn_arg ) : #NEWLINE# #INDENT# key = ( analyzer , fn_arg . cache_key ) #NEWLINE# if ( key in _cache ) : #NEWLINE# #INDENT# return _cache [ key ] #NEWLINE# #UNINDENT# result = analyzer ( fn_arg ) #NEWLINE# _cache [ key ] = result #NEWLINE# return result #NEWLINE# #UNINDENT# return memoized