On Thu, Mar 3, 2011 at 7:08 AM, luisfe <lftab...@yahoo.es> wrote: > Could someone highlight why the following happens? > > from a sage session, the names that can be imported from > sage.rings.integer_ring are: > > {{{ > EuclideanDomains Z factor > is_IntegerRing > IntegerRing ZZ factorization ring > IntegerRing_class arith gmp_randrange sage > ParentWithGens clear_mpz_globals init_mpz_globals > Sequence crt_basis integer_ring_python > }}} > > However, from a sage -ipython session we have the following: > > {{{ > IntegerRing clear_mpz_globals factor > init_mpz_globals > IntegerRing_class crt_basis gmp_randrange > is_IntegerRing > }}} > > Imported names and variables defined without def are not available in > ipython?
I'm not following you dhcp-172-31-80-120:~ robertwb$ sage -ipython Python 2.6.4 (r264:75706, Nov 17 2010, 02:06:41) Type "copyright", "credits" or "license" for more information. IPython 0.9.1 -- An enhanced Interactive Python. ? -> Introduction and overview of IPython's features. %quickref -> Quick reference. help -> Python's own help system. object? -> Details about 'object'. ?object also works, ?? prints more. In [1]: import sage.all In [2]: dir(sage.rings.integer_ring) Out[2]: ['EuclideanDomains', 'IntegerRing', 'IntegerRing_class', 'ParentWithGens', 'Sequence', 'Z', 'ZZ', '__builtins__', '__doc__', '__file__', '__name__', '__package__', 'clear_mpz_globals', 'crt_basis', 'factor', 'factorization', 'gmp_randrange', 'init_mpz_globals', 'integer_ring_python', 'is_IntegerRing', 'ring', 'sage'] > I suspect that this has to do with cython and extension modules and > has a bad impact on lazy_import since not all names can be > lazy_imported. Why? They look like they're all there to me. > Moreover, on a pure ipython session it is trivial to > get segfaults unless one import all from sage.all > > {{{ > $ sage -ipython > In [1]: from sage.rings.integer_ring import * > ... > AttributeError: 'module' object has no attribute 'ZZ' > In [2]: from sage.rings.integer_ring import * > > In [3]: IntegerRing() > > > ------------------------------------------------------------ > Unhandled SIGSEGV: A segmentation fault occurred in Sage. > This probably occurred because a *compiled* component > of Sage has a bug in it (typically accessing invalid memory) > and is not properly wrapped with sig_on(), sig_off(). > You might want to run Sage under gdb with 'sage -gdb' to debug this. > Sage will now terminate (sorry). > ------------------------------------------------------------ > }}} Yes, this fragility is a known bug, and one of the reasons I mentioned doing a lazy import of everything the global namespace is not going to work. - Robert -- To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org