Skip to content

Instantly share code, notes, and snippets.

@justmytwospence
Created July 10, 2014 18:44
Show Gist options
  • Save justmytwospence/625f6b87534fa7eca563 to your computer and use it in GitHub Desktop.
Save justmytwospence/625f6b87534fa7eca563 to your computer and use it in GitHub Desktop.

Revisions

  1. Spencer Boucher created this gist Jul 10, 2014.
    10 changes: 10 additions & 0 deletions cache.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,10 @@
    def cache(func):
    saved = {}
    @wraps(func)
    def newfunc(*args):
    if args in saved:
    return newfunc(*args)
    result = func(*args)
    saved[args] = result
    return result
    return newfunc