start-up time in sage scripts

57 views
Skip to first unread message

samontab

unread,
Aug 2, 2011, 1:10:30 PM8/2/11
to sage-support
Hi,

First of all, Sage is awesome, thanks for putting everything together
and making this happen...

I have a problem though, I would like to use Sage for many small
calculations on demand. This is fine if I am using Sage manually, but
when I want to automate these calculations creating scripts, it takes
a lot of time to run them.

Every time Sage starts, it takes some time for loading. Once it is
loaded, calculations perform fast. The problem I am having is that
every time I run a script, Sage has to start from scratch, so the
calculation takes a lot of time, even when the calculations itself are
trivial.

The only solution I can think of is hacking the notebook() interface
so that I can access it through the command line, and evaluate my
scripts with it as the evaluate link does in the web interface. Is
there any other way I could keep the Sage environment loaded while
calling the scripts? Am I missing something obvious? or do you have
any hints on how can I use that server to run the scripts?

Ivan Andrus

unread,
Aug 6, 2011, 7:44:08 AM8/6/11
to sage-s...@googlegroups.com

Yes, this is one of the things that also frustrates me. There is some work being done on it, in fact it's the first item on the Sage Days 32 wishlist: http://wiki.sagemath.org/days32/wishlist

Instead of hacking the notebook, you can just use the simple server API:
http://www.sagemath.org/doc/reference/sagenb/simple/twist.html
or perhaps the new single cell computer server:
http://sagemath.org:5467/

-Ivan

Rado

unread,
Aug 6, 2011, 12:19:43 PM8/6/11
to sage-s...@googlegroups.com
You can check what Sage-mode for emacs has done. Admittedly I never used it, but it should resolve this problem exactly.

Ivan Andrus

unread,
Aug 6, 2011, 4:09:38 PM8/6/11
to sage-s...@googlegroups.com
On Aug 6, 2011, at 6:19 PM, Rado wrote:

> You can check what Sage-mode for emacs has done. Admittedly I never used it, but it should resolve this problem exactly.

You may also want to check out https://github.com/jasongrout/sage-forker which allows for instantaneous start up of an interactive shell.

-Ivan

Jason Grout

unread,
Aug 6, 2011, 11:26:02 PM8/6/11
to sage-s...@googlegroups.com

I have an updated version of that which I have not posted yet. Sometime
next week... It solves some problems like:

1. forking erases history

2. forking always starts in the same directory as the original server,
not in the current working directory

3. the pipe was not specific to a computer (important when you're on NFS
and trying to run a forking server for multiple computers with a shared
home directory)

and a few other things...

Jason


Ivan Andrus

unread,
Aug 7, 2011, 9:43:21 AM8/7/11
to sage-s...@googlegroups.com

It would be awesome if this could be made into sage commands something along the lines of

sage --start-shell-server

and then `sage` could check if a server was started and if so, use that. Or even if I had to use `sage --client` or something. I tried doing this once, but I never figured out how to turn it into a python module. I'm a total cython newb. :-(

In other words, I would review it :-)

-Ivan

samontab

unread,
Aug 12, 2011, 11:42:28 AM8/12/11
to sage-support
Thanks for the suggestions.

sage forker works fine on my machine. The startup of sage is almost
instant now. I have a problem though. Normally I would call sage
scripts like this:

sage script.sage

I tried using fsage for executing the scripts:

./fsage script.sage

But it only starts sage (very fast though), without executing the
script. Is it possible to do such thing?.

If that cannot be done, I guess my only choice will be to use the
simple web server.... but it does not support the console commands
like "ls", "pwd", etc. (or at least I can't get them to work).

On Aug 6, 11:26 pm, Jason Grout <jason-s...@creativetrax.com> wrote:
> On 8/6/11 4:09 PM, Ivan Andrus wrote:
>
> > On Aug 6, 2011, at 6:19 PM, Rado wrote:
>
> >> You can check what Sage-mode for emacs has done. Admittedly I never used it, but it should resolve this problem exactly.
>
> > You may also want to check outhttps://github.com/jasongrout/sage-forkerwhich allows for instantaneous start up of an interactive shell.

Jason Grout

unread,
Aug 12, 2011, 11:58:40 AM8/12/11
to sage-s...@googlegroups.com
On 8/12/11 10:42 AM, samontab wrote:
> Thanks for the suggestions.
>
> sage forker works fine on my machine. The startup of sage is almost
> instant now. I have a problem though. Normally I would call sage
> scripts like this:
>
> sage script.sage
>
> I tried using fsage for executing the scripts:
>
> ./fsage script.sage
>
> But it only starts sage (very fast though), without executing the
> script. Is it possible to do such thing?.
>


You'll have to change the code for fsage to accept a command-line
argument and execute "load script.sage" or something like that.

Jason

Reply all
Reply to author
Forward
0 new messages