#11287: Interface to runsnake and import_statements
------------------------------------------+---------------------------------
Reporter: nthiery | Owner: tbd
Type: enhancement | Status: needs_review
Priority: major | Milestone: sage-4.7.1
Component: performance | Keywords: runsnake, prun,
profiling
Work_issues: | Upstream: N/A
Reviewer: Franco Saliola, Simon King | Author: Nicolas M. ThiƩry
Merged: | Dependencies:
------------------------------------------+---------------------------------
Changes (by SimonKing):
* reviewer: Franco Saliola => Franco Saliola, Simon King
Comment:
'''Runsnake'''
Can you give at least a slight hint how to use runsnake? I used
easy_install inside a Sage shell, but apparently something (wxPython?) is
missing. I thought easy_install is supposed to take care of dependencies.
Also, I think you should give examples how to use the profiler from within
Sage. From runsnake's documentation, I guess one does something like
{{{
sage: import cProfile
sage: cProfile.run'L=[singular(i)==gap(i)==i+1 for i in range(2000)]'
cProfile.run cProfile.runctx
sage: cProfile.runctx('L=[singular(i)==gap(i)==i+1 for i in range(2000)]',
globals(),locals(), filename="OpenGLContext.profile" )
}}}
but what afterwards?
Does one need to leave Sage, start a Sage shell, and then open
`OpenGLContext.profile` by `runsnake OpenGLContext.profile`? (That step
did not work for me, it seems I need to get wx)
Can one use it without leaving Sage?
'''import_statements'''
That tool seems useful. I doubt, however, that it is robust enough. I see
that you ask for the `__module__` attribute. It is not always present, at
least for methods or for extension classes that forgot to initialise the
category:
{{{
sage: from sage.structure.element import Element
sage: Element.parent.__module__
---------------------------------------------------------------------------
AttributeError Traceback (most recent call
last)
/mnt/local/king/SAGE/sage-4.7.alpha5/<ipython console> in <module>()
AttributeError: 'method_descriptor' object has no attribute '__module__'
sage: P.<x,y> = QQ[]
sage: P.__module__
---------------------------------------------------------------------------
AttributeError Traceback (most recent call
last)
/mnt/local/king/SAGE/broken/devel/sage-main/<ipython console> in
<module>()
/mnt/local/king/SAGE/broken/local/lib/python2.6/site-
packages/sage/structure/parent.so in
sage.structure.parent.Parent.__getattr__ (sage/structure/parent.c:5618)()
/mnt/local/king/SAGE/broken/local/lib/python2.6/site-
packages/sage/structure/parent.so in
sage.structure.parent.raise_attribute_error
(sage/structure/parent.c:2636)()
AttributeError:
'sage.rings.polynomial.multi_polynomial_libsingular.MPolynomialRing_libsingular'
object has no attribute '__module__'
}}}
Worse, the `__module__` attribute can be misleading. Unfortunately, it is
particularly misleading if you initialise the category of a parent:
{{{
sage: P._is_category_initialized()
False
sage: P._init_category_(Algebras(QQ))
sage: P.__module__
'sage.categories.algebras'
sage: import_statements(P)
from sage.categories.category import CommutativeAlgebras.parent_class
}}}
That import statement yields a syntax error.
Also, I recall that sometimes the `__module__` attribute is `None` (but I
can't remember a typical example).
I would recommend to use the tools from sage.misc.sageinspect, but only
after applying #9976, which considerably extends the capabilities of
finding source files (here:
sage/rings/polynomial/multi_polynomial_libsingular.pyx), from which one
can deduce the import statement.
I am not sure if this is enough to make it "needs work", though.
Cheers,
Simon
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/11287#comment:5>
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.