Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1252)

Side by Side Diff: mojo/tools/mopy/memoize.py

Issue 728783003: Add infrastructure to run tests on android. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Follow review Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « mojo/tools/mopy/file_hash.py ('k') | mojo/tools/mopy/transitive_hash.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 # Copyright 2014 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
4
5 import sys
6
7 # pylint: disable=C0301
8 # Based on/taken from
9 # http://code.activestate.com/recipes/578231-probably-the-fastest-memoization- decorator-in-the-/
10 # (with cosmetic changes).
11 # pylint: enable=C0301
12 def memoize(f):
13 """Memoization decorator for a function taking a single argument."""
14 class Memoize(dict):
15 def __missing__(self, key):
16 rv = self[key] = f(key)
17 return rv
18 return Memoize().__getitem__
OLDNEW
« no previous file with comments | « mojo/tools/mopy/file_hash.py ('k') | mojo/tools/mopy/transitive_hash.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698