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

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

Issue 878933003: Move the apptest runner and parts of mopy to the public SDK. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 10 months 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
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/gtest_list_tests_unittest.py ('k') | mojo/tools/mopy/mojo_python_tests_runner.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698