Preserving Mathematica expressions in a textual form -
what proper way convert mathematica expressions losslessly string (a string kept in memory, not exported file)?
i looking textual representation that
- will preserve information, including keeping special (and possibly atomic) objects, such
sparsearray,graph,dispatch,compiledfunction, etc. intact. e.g. cyclingsparsearraythrough representation should keep sparse (and not convert normal list). - is relatively fast cycle through (convert , forth).
is tostring[expr, fullform] sufficient this? tostring[expr, inputform]?
note 1: came while trying work around bugs in graph internal representation gets corrupted occasionally. i'm interested in answer general question above.
note 2: save surely this, writes files (probably possible solve using streams), , write definitions associated symbols.
if not going perform string manipulations on resulting string, may consider compress , uncompress alternative tostring. while don't know cases tostring[expr,inputform] - toexpression cycles break, can imagine exist. compress solution seems more robust, uncompress invoked on compress-ed string guaranteed reconstruct original expression. added advantage of compress is pretty memory-efficient - used few times save large amounts of numerical data in notebook, without saving them disk.
Comments
Post a Comment