diff options
author | Raymond Hettinger <python@rcn.com> | 2012-04-29 19:28:02 (GMT) |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2012-04-29 19:28:02 (GMT) |
commit | 678e7f3be658df7e1bd06bb0c37d820143f15eca (patch) | |
tree | a4a49ce5c94d4847cd0d48208e2dcd686c2d4aee | |
parent | 1182351e69c81b95186a5318f28a6e1bd2fc0a2f (diff) | |
download | cpython-678e7f3be658df7e1bd06bb0c37d820143f15eca.zip cpython-678e7f3be658df7e1bd06bb0c37d820143f15eca.tar.gz cpython-678e7f3be658df7e1bd06bb0c37d820143f15eca.tar.bz2 |
Flatten the lru cache keyword args tuple for better memory utilization.
-rw-r--r-- | Lib/functools.py | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/Lib/functools.py b/Lib/functools.py index ae4175d..1e7795f 100644 --- a/Lib/functools.py +++ b/Lib/functools.py @@ -185,7 +185,9 @@ def lru_cache(maxsize=100, typed=False): key = args if kwds: sorted_items = tuple(sorted(kwds.items())) - key += kwd_mark + sorted_items + key += kwd_mark + key += tuple(k for k, v in sorted_items) + key += tuple(v for k, v in sorted_items) if typed: key += tuple(type(v) for v in args) if kwds: |