From c6afbfc820d98e91aff028fb0e7f455a53abae42 Mon Sep 17 00:00:00 2001 From: neingeist Date: Sat, 30 Aug 2014 08:16:50 +0200 Subject: [PATCH] fix whitespace a little --- json_memoize.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/json_memoize.py b/json_memoize.py index 6df65b5..1101516 100644 --- a/json_memoize.py +++ b/json_memoize.py @@ -7,6 +7,7 @@ import os class HashableDict(dict): + def __hash__(self): return hash(tuple(sorted(self.items()))) @@ -25,7 +26,6 @@ def json_memoize(filename): json.dump({}, f) def __call__(self, *args, **kwargs): - with open(filename, "r") as f: memo = json.load(f) json_key = repr((self.fn.__name__, args, HashableDict(kwargs))) @@ -86,10 +86,10 @@ def some_with_kwargs(one, two, **kwargs): return one + two + reduce(operator.add, [kwargs[k] for k in kwargs], 0) -assert (is_prime(0) is False) -assert (is_prime(1) is False) -assert (is_prime(2) is True) -assert (is_prime(2 * 3 * 4 * 5 * 6 * 7 * 8 * 9 * 10) is False) +assert(is_prime(0) is False) +assert(is_prime(1) is False) +assert(is_prime(2) is True) +assert(is_prime(2 * 3 * 4 * 5 * 6 * 7 * 8 * 9 * 10) is False) is_prime_timed = timed(is_prime) for c in range(1, 11):