In [1]:
from fito import DictDataStore, as_operation

ds = DictDataStore()

@as_operation(out_data_store=ds)
def f(x, y=1):
    print "Executed!"
    return x + y

In [2]:
def execute(*input):
    print "Calling f({})".format(', '.join(map(str, input)))
    print f(*input).execute()
    print

In [3]:
# will execute f
execute(1)

print "Cache contents"
print ds.data
print

# cache hit!
execute(1)

print "Emptying cache..."
ds.data = {}

# sohuld print executed again
execute(1)

execute(1, 2)


Calling f(1)
Executed!
2

Cache contents
{f(y=1, x=1): 2}

Calling f(1)
2

Emptying cache...
Calling f(1)
Executed!
2

Calling f(1, 2)
Executed!
3