class Memo(dict): \ get = lambda s, k: (len(s) > 1000 and s.clear()) or \ (k in s and s[k]) or s.setdefault(k, s.f(k)); \ f = lambda s, k: # your code here
I'm Brett Slatkin and this is where I write about programming and related topics. You can contact me here or view my projects.
05 June 2013
@
22:02
Shortest memo cache
About
I'm the author of the book
Effective Python. I'm a software engineer at Google (currently in the Office of the CTO) where I've worked for the past 19 years. Follow @haxor on Twitter
if you'd like to read posts from me in the future. You can also
email me here.
© 2009-2024 Brett Slatkin