Object persistence

You can load and save most Sage object to disk using the load and save member functions and commands.

Note

It is impossible to save certain Sage objects to disk. For example, if x is a MAGMA object, i.e., a wrapper around an object that is defined in MAGMA, there is no way to save x it to disk, since MAGMA doesn’t support saving of individual objects to disk.

  • Versions: Loading and saving of objects is guaranteed to work even if the version of Python changes. Saved objects can be loaded in future versions of Python. However, if the data structure that defines the object, e.g., in Sage code, changes drastically (or changes name or disappears), then the object might not load correctly or work correctly.
  • Objects are zlib compressed for space efficiency.
sage.misc.persist.db(name)

Load object with given name from the Sage database. Use x.db(name) or db_save(x, name) to save objects to the database.

The database directory is $HOME/.sage/db.

sage.misc.persist.db_save(x, name=None)

Save x to the Sage database.

The database directory is $HOME/.sage/db.

sage.misc.persist.load_sage_element(cls, parent, dic_pic)
sage.misc.persist.load_sage_object(cls, dic)

Previous topic

Logging of Sage sessions.

Next topic

Support for persistent functions in .sage files.

This Page