#15657: Allow parsing of arguments for cached_function and cached_method
-------------------------------------+-------------------------------------
       Reporter:  tscrim             |        Owner:  tscrim
           Type:  enhancement        |       Status:  needs_review
       Priority:  major              |    Milestone:  sage-6.2
      Component:  misc               |   Resolution:
       Keywords:  cached method      |    Merged in:
  function                           |    Reviewers:
        Authors:                     |  Work issues:
Report Upstream:  N/A                |       Commit:
         Branch:                     |  275f2e1ef53456964cf49b81aab22ffdecb308c3
  public/structure/cached_args-15657 |     Stopgaps:
   Dependencies:                     |
-------------------------------------+-------------------------------------
Changes (by tscrim):

 * cc: SImonKing (removed)
 * cc: SimonKing (added)
 * commit:  fe7a01a75ef3d52f1aa85ee48301377795520384 =>
     275f2e1ef53456964cf49b81aab22ffdecb308c3
 * branch:  u/saraedum/ticket/15657 => public/structure/cached_args-15657


Comment:

 I've changed `create_key` into `key` to match with python's `sorted` (and
 it makes more sense to me). I've also moved a good part of the doc up to
 our current standards.

 Here are some timings:

 With patch:
 {{{
 sage: @cached_function
 ....: def foo():
 ....:     return 5
 ....:
 sage: %timeit foo()
 1000000 loops, best of 3: 343 ns per loop

 sage: class Foo:
 ....:     @cached_method
 ....:     def bar(self):
 ....:         return 5
 ....:
 sage: F = Foo()
 sage: %timeit F.bar()
 1000000 loops, best of 3: 235 ns per loop

 sage: class FooArgs:
 ....:     @cached_method
 ....:     def bar(self, x):
 ....:         return x
 ....:
 sage: FA = FooArgs()
 sage: %timeit FA.bar(5)
 1000000 loops, best of 3: 1.55 µs per loop
 }}}
 Before:
 {{{
 sage: %timeit foo()
 1000000 loops, best of 3: 335 ns per loop

 sage: %timeit F.bar()
 1000000 loops, best of 3: 250 ns per loop

 sage: %timeit FA.bar(5)
 1000000 loops, best of 3: 1.47 µs per loop
 }}}
 So there does not appear to be any (statistically) significant speed
 regression (I did multiple runs of each as well).

 If you're happy with my changes, then positive review.
 ----
 New commits:
 
||[http://git.sagemath.org/sage.git/commit/?id=ec8dbf14f0b9d888b5bd1179998a406b0151a8c4
 ec8dbf1]||{{{Initial addition of a 'key' argument to cached
 functions.}}}||
 
||[http://git.sagemath.org/sage.git/commit/?id=c5e837be63b05b4292ca10024d9c774b937a3a7c
 c5e837b]||{{{Merge branch 'develop' into
 public/structure/cached_args-15657}}}||
 
||[http://git.sagemath.org/sage.git/commit/?id=8d78b1bcfe56043474663ca484ff48bdffc36c3d
 8d78b1b]||{{{Merge branch 'develop' into
 public/structure/cached_args-15657}}}||
 
||[http://git.sagemath.org/sage.git/commit/?id=5872e555b146e425ccfb1142ef835823b007d6bb
 5872e55]||{{{Merge branch 'develop' into
 public/structure/cached_args-15657}}}||
 
||[http://git.sagemath.org/sage.git/commit/?id=9374110c7059ed38d7bac74f7e4a0df1daa0e304
 9374110]||{{{Merge branch 'develop' into
 public/structure/cached_args-15657}}}||
 
||[http://git.sagemath.org/sage.git/commit/?id=03ac296c9e5af190db54c936ce6fffc4bf409236
 03ac296]||{{{Merge branch 'u/saraedum/ticket/15657' of
 trac.sagemath.org:sage into public/structure/cached_args-15657}}}||
 
||[http://git.sagemath.org/sage.git/commit/?id=275f2e1ef53456964cf49b81aab22ffdecb308c3
 275f2e1]||{{{Fixes due to my bad merging skills.}}}||

--
Ticket URL: <http://trac.sagemath.org/ticket/15657#comment:7>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica, 
and MATLAB

-- 
You received this message because you are subscribed to the Google Groups 
"sage-trac" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/d/optout.

Reply via email to