#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| 
 a0b829dc10b4ccb00b99e073de8a1c0006aa1e51
   Dependencies:                     |     Stopgaps:
-------------------------------------+-------------------------------------

Comment (by nbruin):

 If we need to access argument information on cython functions/methods, we
 might consider using
 {{{
 cython("""
 import cython
 @cython.binding(True)
 def f(a,b=0): pass

 def g(a,b=0): pass

 def c(F,n_in):
   cdef int n=n_in
   for i in range(n):
     F(1)
 """)
 }}}
 With this we have
 {{{
 sage: f.func_defaults
 (0,)
 sage: f.__code__.co_varnames
 ('a', 'b')
 }}}
 There might be a penalty to pay, though:
 {{{
 sage: %time c(f,1000000000)
 CPU times: user 7.7 s, sys: 10 ms, total: 7.71 s
 Wall time: 8.06 s
 sage: %time c(g,1000000000)
 CPU times: user 7.43 s, sys: 13 ms, total: 7.45 s
 Wall time: 7.78 s
 }}}
 If we can do away with source file inspection during startup (as would now
 happen for cython modules), we should see a significant improvement of
 startup time too! Finding line numbers in a text file is not a fast
 operation.

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