changelog shortlog graph tags branches changeset files revisions annotate raw help

hash3.py

changeset 92: 67c5274c3826
parent: 23bc93c7bc58
child: 71c013a28bc2
author: 127.0.0.1
date: Fri, 06 Dec 2013 23:35:55 +0100
permissions: -rw-r--r--
description: created
1 import functools
2 
3 def memoize(func):
4  cache = {}
5  @functools.wraps(func)
6  def wrapped(*args, **kwargs):
7  key = args, tuple(kwargs.iteritems())
8  try:
9  result = cache[key]
10  except KeyError:
11  result = cache[key] = func(*args, **kwargs)
12  return result
13  return wrapped
14 
15 @memoize
16 def show(what):
17  print what
18 
19 show(what="something")
20 show(what="something")