Opened 12 years ago
Closed 8 years ago
#5475 closed defect (duplicate)
[with patch, needs work] make it so ipython isn't imported when one does "sage -python"
Reported by: | was | Owned by: | was |
---|---|---|---|
Priority: | major | Milestone: | sage-duplicate/invalid/wontfix |
Component: | interfaces | Keywords: | |
Cc: | Merged in: | ||
Authors: | Reviewers: | ||
Report Upstream: | N/A | Work issues: | |
Branch: | Commit: | ||
Dependencies: | Stopgaps: |
Description
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; }
Attachments (1)
Change History (4)
Changed 12 years ago by
comment:1 Changed 12 years ago by
- Summary changed from make it so ipython isn't imported when one does "sage -python" to [with patch, needs review] make it so ipython isn't imported when one does "sage -python"
comment:2 Changed 12 years ago by
- Milestone changed from sage-3.4 to sage-3.4.1
- Summary changed from [with patch, needs review] make it so ipython isn't imported when one does "sage -python" to [with patch, needs work] make it so ipython isn't imported when one does "sage -python"
comment:3 Changed 8 years ago by
- Milestone changed from sage-5.11 to sage-duplicate/invalid/wontfix
- Report Upstream set to N/A
- Resolution set to duplicate
- Status changed from needs_work to closed
This is a duplicate of #3685.
Note: See
TracTickets for help on using
tickets.
This patch causes some doctesting trouble:
Cheers,
Michael