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 2008/11/2 Daniel Allcock <[EMAIL PROTECTED]>: > > Hi all, just got started with SAGE and I hope someone has a suggestion > for me. I have a .sage file defining a big list of approx 170,000 4x4 > matrices with rational number entries, which I will want SAGE to do > various things to. It takes SAGE 4-5 minutes to read in the file > (which was produced by a C++ program), and surely this can be > improved. > > I assumed that loading it into memory and then writing it to a .sobj > file would give me something more manageable. But I get memory > allocation errors: > > python(2102) malloc: *** vm_allocate(size=8421376) failed (error > code=3) > python(2102) malloc: *** error: can't allocate region > python(2102) malloc: *** set a breakpoint in szone_error to debug > > Presumably the system has just run out of memory. This surprises me > since the .sage file is only 12MB, and the .py file it creates is > 37MB. The matrix entries are all small, numerators <10,000 and > denominators < 200 or so. I'm working on a MacBook Pro with 2GB RAM, > and the machine didn't have any other substantial load. > > I will need only one matrix at a time, so there should be no need to > load in all of them at once. But poking around in SAGE and python > docs hasn't shown me any simple way to, say, read in and execute a > single line from some file. > > Thanks for your help, > Daniel > > > > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---