On Nov 3, 9:13 am, "John Cremona" <[EMAIL PROTECTED]> wrote:
> Does this help you:
>
> Suppose (for a toy example) I have defined a Python function like this:
> sage: def f(M):
> ....:         d = M.det()
> ....:     return d
>
> And I have a file called testin.sage containing a large number of
> lines like this:
>
> [[1,2],[3,4]]
> [[5,6],[7,8]]
> [[1,2],[3,4]]
> [[5,6],[7,8]]
> [[1,2],[3,4]]
> [[5,6],[7,8]]
>
> Then from the command line I can do this:
>
> sage: for l in open("/home/masgaj/testin.sage"):
>     print(f(Matrix(eval(l))))
>
> and what I see is this:
> -2
> -2
> -2
> -2
> -2
> -2
>
> As far as I know Python only reads the lines in the file one at at
> time, and returns each as a string (hence the eval()), which you can
> do what you like with.
>
> I did something similar when I wanted to process a million elliptic
> curves without reading them all in at once.
>
> John

Yep, the "load" is the expensive operation:

[EMAIL PROTECTED]:/scratch/mabshoff/release-cycle/sage-3.1.3.final$ ./sage
----------------------------------------------------------------------
| Sage Version 3.2.alpha2, Release Date: 2008-10-31                  |
| Type notebook() for the GUI, and license() for information.        |
----------------------------------------------------------------------

sage: time load SPOCs.sage
 CPU times: user 67.46 s, sys: 8.94 s, total: 76.40 s
Wall time: 76.59 s
sage:  get_memory_usage()
3700.5625
sage: time save (SPOC,'SPOCs.sobj')
CPU times: user 17.63 s, sys: 0.08 s, total: 17.71 s
Wall time: 17.71 s
sage:  get_memory_usage()
3700.5625
sage:
Exiting SAGE (CPU time 7m27.07s, Wall time 18m2.26s).


[EMAIL PROTECTED]:/scratch/mabshoff/release-cycle/sage-3.1.3.final$ ./sage
----------------------------------------------------------------------
| Sage Version 3.2.alpha2, Release Date: 2008-10-31                  |
| Type notebook() for the GUI, and license() for information.        |
----------------------------------------------------------------------

sage: time load('SPOCs.sobj')

CPU times: user 7.10 s, sys: 0.60 s, total: 7.70 s
Wall time: 7.70 s

What is off is that according to top the load operation took about 600
seconds CPU time, so where is the time going?

Cheers,

Michael
--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

Reply via email to