Ask Your Question

Object Persistence

asked 2012-10-24 13:29:13 -0600

SLOtoSF gravatar image

Is Object Persistence faster than just recreating the object? Why? And how do I do it, what are the steps? I read this:, but am unclear about the parameters and how it works. Does this object only get associated with me as a user of the notebook, or can I share this object with other users (like if want to explore the properties of a clique graph on 20 nodes, which took 20 minutes to construct, how can I make that available to others?)

Sorry for all the questions, primarily I'm interested in how I can user Object Persistence to make my life easier.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2012-10-25 16:16:35 -0600

benjaminfjones gravatar image

Yes, you can save and restore computed objects easily. This will be faster if the time to load the object from disk is lower than the time to compute it. Certainly, an object that takes 20 minutes to compute is going to be faster to load from a saved state on disk than it is to recompute. The saved state is just a file that Sage can restore to an object in memory, so you can certainly share such saved objects with others.

Have a look at the save and load functions. Here's an example of their use:

sage: E = EllipticCurve([-1,0])
sage: save(E, 'elliptic')
sage: quit


sage: E = load('elliptic.sobj')
sage: E
Elliptic Curve defined by y^2 = x^3 - x over Rational Field

If you are working in the Sage notebook, saved object files will be stores in the DATA directory. If you want to share the object with someone else, I think you need to download the worksheet from the server and send that (it will contain the saved object file).

edit flag offensive delete link more


Thanks @benjaminfjones, What if the object has other custom objects as attributes to it, will those get carried over too? I'm just wondering about the dependencies....

SLOtoSF gravatar imageSLOtoSF ( 2012-10-26 13:33:05 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools


Asked: 2012-10-24 13:29:13 -0600

Seen: 68 times

Last updated: Oct 25 '12