Fast-to-load cross-platform alternative to MX files (Mathematica)
In Mathematica, one can save intermediate results / the partial state of the workspace with Save
(.m files) or DumpSave
(.mx files).
.m files are portable, but are very slow to load (with large data).
.mx files are fast to load, but are not portable between platforms/architectures.
Is there a way to save generic Mathematica expressions in a way that loading them is fast, and they're portable between platforms? Has anyone experimented with / benchmarked different methods to do this?
One possible solution is to save .m files (cross-platform), then convert them to .mx files when starting work on a new platform (a one-time operation). Is there a ful开发者_运维知识库ly automatic way to convert .m files to .mx files?
From the posts Alexey linked:
str=OpenWrite[file,BinaryFormat->True]; BinaryWrite[str,Compress[expr],"TerminatedString"]; Close[str];
This is not quite as fast as using an mx file, but it is still very fast.
David Bailey
Another alternative seems to be WDX (Wolfram Data eXchange) which I am using without problems on a variety of machines and which also seems to be portable, can be used exactly like MX files, is binary, is documented and thus I would consider officially supported. And it is used by the data paclet functionality, so I guess it is reasonably performant and well tested on all systems (an assumption which my experience does support up to now).
(excerpt from answer by Albert Retey, also from Alexey's link)
But these do not work as Save
/DumpSave
does, in that it does not save the FullDefinition
of expr
, only the explicit value of expr
.
精彩评论