ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Fri, 26 Oct 2012 20:33:05 +0200Object Persistencehttps://ask.sagemath.org/question/9466/object-persistence/Is Object Persistence faster than just recreating the object? Why? And how do I do it, what are the steps? I read this: http://www.sagemath.org/doc/reference/sage/misc/persist.html, 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.Wed, 24 Oct 2012 20:29:13 +0200https://ask.sagemath.org/question/9466/object-persistence/Answer by benjaminfjones for <p>Is Object Persistence faster than just recreating the object? Why? And how do I do it, what are the steps? I read this: <a href="http://www.sagemath.org/doc/reference/sage/misc/persist.html">http://www.sagemath.org/doc/reference...</a>, 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?)</p>
<p>Sorry for all the questions, primarily I'm interested in how I can user Object Persistence to make my life easier.</p>
https://ask.sagemath.org/question/9466/object-persistence/?answer=14195#post-id-14195Yes, 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
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).Thu, 25 Oct 2012 23:16:35 +0200https://ask.sagemath.org/question/9466/object-persistence/?answer=14195#post-id-14195Comment by SLOtoSF for <p>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.</p>
<p>Have a look at the <code>save</code> and <code>load</code> functions. Here's an example of their use:</p>
<pre><code>sage: E = EllipticCurve([-1,0])
sage: save(E, 'elliptic')
sage: quit
</code></pre>
<p>....</p>
<pre><code>>sage
sage: E = load('elliptic.sobj')
sage: E
Elliptic Curve defined by y^2 = x^3 - x over Rational Field
</code></pre>
<p>If you are working in the Sage notebook, saved object files will be stores in the <code>DATA</code> 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).</p>
https://ask.sagemath.org/question/9466/object-persistence/?comment=18809#post-id-18809Thanks @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....Fri, 26 Oct 2012 20:33:05 +0200https://ask.sagemath.org/question/9466/object-persistence/?comment=18809#post-id-18809