[MRG] Improve doc about caching methods#432
Conversation
|
@smidm do let me know if something is not crystal clear with the new doc, in particular if this would not have helped you on your particular issue. |
12b7011 to
8ff3055
Compare
Recommend to cache pure functions that you call inside a method
8ff3055 to
70ab78d
Compare
|
This would have pointed me in the right direction. Thanks. |
|
@aabadie @GaelVaroquaux maybe a quick look at this one? |
GaelVaroquaux
left a comment
There was a problem hiding this comment.
Great rewrite. +1
I added a small comment on how I do things these days.
| @mem.cache # WRONG | ||
| def method(self, args): | ||
| pass | ||
| def compute(self): |
There was a problem hiding this comment.
I actually now prefer to use joblib not as an decorator, but as an explicit function transformation, and I would remove the decorator on compute_func and write the following:
self.data = mem.cache(compute_func)(self.arg1, self.arg2, 40)
There was a problem hiding this comment.
I'll merge this PR and get rid of the mem.cache decorators in a separate PR.
Out of interest why do you do it this way, to make it clearer that the function is cached where it is called, to keep the uncached function easily accessible, for some other reasons?
|
to keep the uncached function easily accessible, for some other reasons?
For that specific reason.
|
* commit '0.10.2-55-g660fe5d': (52 commits) MAINT simplify way to skip doctests Do not print frames with IPython internals in format_stack BF(TST): compare for version in pickled filename ignoring full path, and looking for _ as well (joblib#445) [MRG] Remove nose dependency completely. (joblib#441) MAINT add Python 3.5 in setup.py Remove some Python 2.6 specific code [MRG] Make test execution on CI possible through py.test command. (joblib#433) Remove more python 2.6 related code (joblib#440) [MRG] Use commit range for diff in flake8_diff.sh (joblib#439) MAINT remove support for python 2.6 (joblib#437) Improve doc about caching methods (joblib#432) Get the tests passing with py.test MAINT update flake8_diff.sh COSMIT move stdlib imports where they belong [MRG] Replace assert_* methods with "assert" keyword statements. (joblib#430) Reraise when the exception is not a TransportableException (joblib#429) Make sure LICENSE.txt is included in the wheel Add LICENSE.txt Update doc/paralle.rst [MRG+1] Remove all nose imports from test scripts. (joblib#422) ...
* releases: (52 commits) MAINT simplify way to skip doctests Do not print frames with IPython internals in format_stack BF(TST): compare for version in pickled filename ignoring full path, and looking for _ as well (joblib#445) [MRG] Remove nose dependency completely. (joblib#441) MAINT add Python 3.5 in setup.py Remove some Python 2.6 specific code [MRG] Make test execution on CI possible through py.test command. (joblib#433) Remove more python 2.6 related code (joblib#440) [MRG] Use commit range for diff in flake8_diff.sh (joblib#439) MAINT remove support for python 2.6 (joblib#437) Improve doc about caching methods (joblib#432) Get the tests passing with py.test MAINT update flake8_diff.sh COSMIT move stdlib imports where they belong [MRG] Replace assert_* methods with "assert" keyword statements. (joblib#430) Reraise when the exception is not a TransportableException (joblib#429) Make sure LICENSE.txt is included in the wheel Add LICENSE.txt Update doc/paralle.rst [MRG+1] Remove all nose imports from test scripts. (joblib#422) ...
Recommend to cache pure functions that you call inside a method.
Add more information on caveats.
Initiated by #431.