Some tools for developers

sage.misc.dev_tools.import_statements(*objects, **options)

Display import statements for the given objects

INPUT:

  • *objects – a sequence of objects
  • lazy – a boolean (default: True)

EXAMPLES:

sage: import_statements(WeylGroup, lazy_attribute)
from sage.combinat.root_system.weyl_group import WeylGroup
from sage.misc.lazy_attribute import lazy_attribute

If lazy is True, then lazy_import() statements are displayed instead:

sage: import_statements(WeylGroup, lazy_attribute, lazy=True)
from sage.misc.lazy_import import lazy_import
lazy_import('sage.combinat.root_system.weyl_group', 'WeylGroup')
lazy_import('sage.misc.lazy_attribute', 'lazy_attribute')

Todo

This is not correct:

sage: import_statements(ZZ)
from sage.categories.euclidean_domains import EuclideanDomains.parent_class

This should be:

sage: import_statements(ZZ)      # todo: not implemented
from sage.rings.integer_ring import ZZ
sage.misc.dev_tools.runsnake(command)

Graphical profiling with runsnake

INPUT:

  • command – the command to be run as a string.

EXAMPLES:

sage: runsnake("list(SymmetricGroup(3))")        # optional - requires runsnake

command is first preparsed (see preparse()):

sage: runsnake('for x in range(1,4): print x^2') # optional - requires runsnake
1
4
9

runsnake() requires the program runsnake. Due to non trivial dependencies (python-wxgtk, ...), installing it within the Sage distribution is unpractical. Hence, we recommend installing it with the system wide Python. On Ubuntu 10.10, this can be done with:

> sudo apt-get install python-profiler python-wxgtk2.8 python-setuptools
> sudo easy_install RunSnakeRun

See the runsnake website for instructions for other platforms.

runsnake() further assumes that the system wide Python is installed in /usr/bin/python.

Previous topic

Class inheritance graphs

Next topic

Simple profiling tool

This Page