#5475: make it so ipython isn't imported when one does "sage -python"
------------------------+---------------------------------------------------
 Reporter:  was         |       Owner:  was     
     Type:  defect      |      Status:  new     
 Priority:  major       |   Milestone:  sage-3.4
Component:  interfaces  |    Keywords:          
------------------------+---------------------------------------------------
 If one wants to use Sage from a C program, e.g., like this (see below),
 then it's important that "from sage.all import *" not import Ipython.  The
 point of this ticket is make the import of IPython lazy -- and only happen
 if needed.  This will also make "sage -python" and "sage -c" faster, since
 Ipython startup takes significant time.

 {{{
 /*
 sage -sh
 gcc -I$SAGE_LOCAL/include/python2.5
 $SAGE_LOCAL/lib/python/config/libpython2.5.a embed.c -o embed; ./embed

 See http://docs.python.org/extending/embedding.html
 */


 #include <Python.h>

 int
 main(int argc, char *argv[])
 {
   Py_Initialize();
   printf("Loading the Sage library...\n");
   PyRun_SimpleString("from sage.all import *");
   printf("Factoring an integer:\n");
   PyRun_SimpleString("print factor(193048120380)");
   printf("Popping up plot of a function:\n");
   PyRun_SimpleString("x=var('x'); show(plot(sin(x)))");
   printf("Popping up plot of a 3-d function:\n");
   PyRun_SimpleString("x,y=var('x,y'); show(plot3d(sin(x*y)-cos(x-y),
 (x,-4,4),(y,-4,4)))");
   printf("Type 0 then return\n");
   int n;
   scanf("%d",&n);
   printf("Exiting...\n");
   Py_Finalize();
   return 0;
 }
 }}}

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/5475>
Sage <http://sagemath.org/>
Sage - Open Source Mathematical Software: Building the Car Instead of 
Reinventing the Wheel

--~--~---------~--~----~------------~-------~--~----~
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