Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
fslpy
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Michiel Cottaar
fslpy
Commits
a77d968b
Commit
a77d968b
authored
8 years ago
by
Paul McCarthy
Browse files
Options
Downloads
Patches
Plain Diff
Removed some lies from function documentation.
parent
53962e78
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
fsl/utils/memoize.py
+7
-12
7 additions, 12 deletions
fsl/utils/memoize.py
with
7 additions
and
12 deletions
fsl/utils/memoize.py
+
7
−
12
View file @
a77d968b
...
...
@@ -28,17 +28,10 @@ log = logging.getLogger(__name__)
# TODO Make this a class, and add
# a "clearCache" method to it.
def
memoize
(
func
):
"""
Memoize the given function by the value of the input arguments, allowing
the caller to specify which positional arguments (by index) and keyword
arguments (by name) are used for the comparison.
"""
Memoize the given function by the value of the input arguments.
If no positional or keyword arguments are specified, the function is
memoized on all arguments. Note that the arguments used for memoization
must be hashable, as they are used as keys in a dictionary.
:arg args: A list of positional argument indices.
:arg kwargs: A list of keyword argument names.
Note that the arguments used for memoization must be hashable, as they are
used as keys in a dictionary.
"""
cache
=
{}
...
...
@@ -62,6 +55,8 @@ def memoize(func):
try
:
result
=
cache
[
key
]
log
.
debug
(
'
Retrieved from cache[{}]: {}
'
.
format
(
key
,
result
))
except
KeyError
:
result
=
func
(
*
a
,
**
kwa
)
...
...
@@ -111,8 +106,8 @@ def memoizeMD5(func):
def
skipUnchanged
(
func
):
"""
This decorator is intended for use with *setter* functions - a function
which accepts a name and a value, and is intended to set some named
attribute to the given value.
which accepts a name and a value, and is intended to set some named
attribute to the given value.
This decorator keeps a cache of name-value pairs. When the decorator is
called with a specific name and value, the cache is checked and, if the
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment