Elaborating on my comment, the native mathematica package format precisely preserves the definition of symbols:
lst = {1.3566789543235679098765432344564335, N[Pi, 50]};
FullForm[lst[[1]]]
1.3566789543235679098765432344564335`34.132477087997515
Export["test.m", lst];
newlist = Import["test.m"];
FullForm[newlist[[1]]]
1.3566789543235679098765432344564335`34.132477087997515
The "List" format chops to the nearest ascii representation and converts back on import,
Export["testfile", lst, "List"];
newlst = Import["testfile", "List"];
FullForm[newlst[[1]]]
1.3566789543235679098765432344564340000000000000000000000001`33.132477087997515
The difference is very subtle and perhaps inconsequential (here actually one bit difference in a 100+ bit binary representation ). I haven't tested it but I expect .m
is faster too if you have large files to save. Of course the downside is .m
is a unique format that would be difficult for anything else to parse.
Note the third argument to Export
overrides whatever extension the file name has. The third argument corresponding to .m
is "Package"
.
Also ".mx" is binary, which will be faster and smaller than ".m", but may not be portable across systems and versions. (Anybody know the "third argument" name for mx? )
.m
or.mb
format. $\endgroup$.m
or.mb
make? Looks like if I useExport
with the third argument being"List"
, then the output file will be basically a text file, be its extension.m
or.mb
. Or am I missing something here? $\endgroup$.mx
not.mb
$\endgroup$