#17814: Make calling a cached method independent of source code inspection
-------------------------------------+-------------------------------------
       Reporter:  SimonKing          |        Owner:
           Type:  defect             |       Status:  needs_review
       Priority:  major              |    Milestone:  sage-6.6
      Component:  distribution       |   Resolution:
       Keywords:                     |    Merged in:
        Authors:  Simon King         |    Reviewers:
Report Upstream:  N/A                |  Work issues:
         Branch:                     |       Commit:
  
u/SimonKing/make_calling_a_cached_method_independent_of_source_code_inspection| 
 30543e7b283c52cad2fbeb060efe78a74c7b42ba
   Dependencies:                     |     Stopgaps:
-------------------------------------+-------------------------------------

Comment (by SimonKing):

 Soon I will submit another commit. With it, I can do the following:

 I created a file `src/sage/misc/cache_test.pyx` and rebuilt Sage. In fact,
 the new pyx file got compiled even without mentioning it in
 `module_list.py`. Content of the file:
 {{{
 #!python
 from sage.misc.cachefunc import cached_method, cached_function
 from sage.structure.parent cimport Parent

 @cached_function
 def bla(x,y,z=2):
     return (x+y)*z

 cdef class Foo(Parent):
     @cached_method
     def bar(self, a,b, c=1):
         return (a+b)*c
 }}}
 I started a Sage session and got:
 {{{
 sage: from sage.misc.cache_test import Foo, bla
 sage: bla(2,3,2) is bla(2,3,z=2)
 True
 sage: F = Foo()
 sage: F.bar(2,3,2) is F.bar(2,3,c=2)
 True
 }}}
 as expected.

 Then I left Sage, removed `src/sage/misc/cache_test.pyx`. Restarting (but
 not recompiling!) Sage, I now get:
 {{{
 sage: from sage.misc.cache_test import Foo, bla
 sage: bla(2,3,2) is bla(2,3,z=2)
 False
 sage: bla(2,3,2) == bla(2,3,z=2)
 True
 sage: F = Foo()
 sage: F.bar(2,3,2) is F.bar(2,3,c=2)
 False
 sage: F.bar(2,3,2) == F.bar(2,3,c=2)
 True
 sage: bla(2,3,2) is bla(2,3,2)
 True
 sage: F.bar(2,3,2) is F.bar(2,3,2)
 True
 }}}
 So, the argument mangling fails, but at least one can call the wrapped
 functions and methods in the expected way, with a basic level of caching.

 Now the questions are: Would that be enough to declare the problem as
 "fixed for now"? And how to doctest it? Is it possible/reasonable to have
 a source file that is temporarily moved away by its own doctest?

 Branch will soon be updated.

--
Ticket URL: <http://trac.sagemath.org/ticket/17814#comment:38>
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