#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|
b340eebb3cec1d5f273b9c382599f23736045e98
Dependencies: | Stopgaps:
-------------------------------------+-------------------------------------
Changes (by SimonKing):
* status: needs_work => needs_review
Comment:
I am now using the embedded signatures (due to #17847) for introspection.
I preserved the previous commits by merging the previous ticket branch
into the current develop to get the new ticket branch; hopefully the
correct procedure.
In order to demonstrate what is happening, I added a dummy method to a
nested test class provided in sage.misc.nested_class. As it turns out,
there has been a bug in the previous `sage_getargspec` that is now fixed.
I suppose that the bug actually is in Cython:
{{{
sage: from sage.misc.nested_class import MainClass
sage: print MainClass.NestedClass.NestedSubClass.dummy.func_defaults
None
}}}
Actually the default is not None but is a tuple, which is correctly
determined by the new version of `sage_getargspec`:
{{{
sage: sage_getargspec(MainClass.NestedClass.NestedSubClass.dummy)
ArgSpec(args=['self', 'x', 'r'], varargs='args', keywords='kwds',
defaults=((1, 2, 3.4),))
}}}
Moreover, the above does not involve reading the source code. I wrote a
new function that determines the argspec from the embedded signature, and
strips the signature at the same time:
{{{
sage: print MainClass.NestedClass.NestedSubClass.dummy.__doc__
NestedSubClass.dummy(self, x, *args, r=(1, 2, 3.4), **kwds)
File: sage/misc/nested_class.pyx (starting at line 314)
A dummy method to demonstrate the embedding of
method signature for nested classes.
...
sage: from sage.misc.sageinspect import _extract_embedded_signature
sage: print
_extract_embedded_signature(MainClass.NestedClass.NestedSubClass.dummy.__doc__,
'dummy')[0]
File: sage/misc/nested_class.pyx (starting at line 314)
A dummy method to demonstrate the embedding of
method signature for nested classes.
...
sage:
_extract_embedded_signature(MainClass.NestedClass.NestedSubClass.dummy.__doc__,
'dummy')[1]
ArgSpec(args=['self', 'x', 'r'], varargs='args', keywords='kwds',
defaults=((1, 2, 3.4),))
}}}
The tests in sage.misc pass.
--
Ticket URL: <http://trac.sagemath.org/ticket/17814#comment:64>
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.