#11115: Rewrite cached_method in Cython
-----------------------------------------------------+----------------------
   Reporter:  SimonKing                              |          Owner:  jason   
                 
       Type:  enhancement                            |         Status:  
needs_info               
   Priority:  major                                  |      Milestone:  
sage-4.7.2               
  Component:  misc                                   |       Keywords:  
category cython cache    
Work_issues:                                         |       Upstream:  N/A     
                 
   Reviewer:  Nicolas M. ThiƩry, Andrey Novoseltsev  |         Author:  Simon 
King               
     Merged:                                         |   Dependencies:  #9976 
#11298 #11342 #9138
-----------------------------------------------------+----------------------

Comment(by SimonKing):

 Replying to [comment:100 vbraun]:
 > sage: test_meth.__doc__
 > 'File:
 _home_vbraun__sage_temp_volker_desktop_stp_dias_ie_5615_tmp_0_spyx_0.pyx
 (starting at line 6)\nsome doc for a wrapped cython method'

 That is extremely strange. If you look at the `_sage_doc_` method in
 `sage.misc.cachefunc` then you'll find:
 {{{
 #!python
         f = self.f
         if hasattr(f, "func_doc"):
             try:
                 sourcelines = sage_getsourcelines(f)
             except IOError:
                 sourcelines = None
             if sourcelines is not None:
                 import os
                 SAGE_ROOT = os.environ['SAGE_ROOT']
                 filename = sage_getfile(f)
                 # The following is a heuristics to get
                 # the file name of the cached function
                 # or method
                 if filename.startswith(SAGE_ROOT+'/devel/sage/'):
                     filename = filename[len(SAGE_ROOT+'/devel/sage/'):]
                 elif 'site-packages/' in filename:
                     filename = filename.split('site-packages/',1)[1]
                 file_info = "File: %s (starting at line
 %d)"%(filename,sourcelines[1])
                 doc = file_info+(f.func_doc or '')
             else:
                 doc = f.func_doc
         else:
             doc = f.__doc__
         return doc
 }}}
 Here, `self` is `O.wrapped_method`, and thus `f` is `test_meth`. Since a
 Cython function has no attribute `func_doc`, the method `_sage_doc_`
 simply returns `f.__doc__` in our case, which ''does'' contain the file
 information.

 Or is it the case that `test_meth` has a `func_doc` attribute on your
 machine?

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/11115#comment:101>
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 post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sage-trac?hl=en.

Reply via email to