Skip to content

[MRG] Improve doc about caching methods#432

Merged
lesteve merged 1 commit intojoblib:masterfrom
lesteve:improve-memory-doc-about-caching-methods
Dec 1, 2016
Merged

[MRG] Improve doc about caching methods#432
lesteve merged 1 commit intojoblib:masterfrom
lesteve:improve-memory-doc-about-caching-methods

Conversation

@lesteve
Copy link
Copy Markdown
Member

@lesteve lesteve commented Nov 30, 2016

Recommend to cache pure functions that you call inside a method.

Add more information on caveats.

Initiated by #431.

@lesteve
Copy link
Copy Markdown
Member Author

lesteve commented Nov 30, 2016

@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.

@lesteve lesteve force-pushed the improve-memory-doc-about-caching-methods branch from 12b7011 to 8ff3055 Compare November 30, 2016 10:13
Recommend to cache pure functions that you call inside a method
@lesteve lesteve force-pushed the improve-memory-doc-about-caching-methods branch from 8ff3055 to 70ab78d Compare November 30, 2016 10:55
@smidm
Copy link
Copy Markdown

smidm commented Nov 30, 2016

This would have pointed me in the right direction. Thanks.

@lesteve
Copy link
Copy Markdown
Member Author

lesteve commented Nov 30, 2016

@aabadie @GaelVaroquaux maybe a quick look at this one?

Copy link
Copy Markdown
Member

@GaelVaroquaux GaelVaroquaux left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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):
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

Copy link
Copy Markdown
Member Author

@lesteve lesteve Dec 1, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

@lesteve lesteve merged commit cf3f631 into joblib:master Dec 1, 2016
@lesteve lesteve deleted the improve-memory-doc-about-caching-methods branch December 1, 2016 14:20
@GaelVaroquaux
Copy link
Copy Markdown
Member

GaelVaroquaux commented Dec 1, 2016 via email

yarikoptic added a commit to yarikoptic/joblib that referenced this pull request Dec 8, 2016
* 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)
  ...
yarikoptic added a commit to yarikoptic/joblib that referenced this pull request Dec 8, 2016
* 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)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants