4
$\begingroup$

.mx is blazingly fast relative to .wl(.m)

Unfortunately, it is not terribly portable. Word-on-the-street is that it's cross-system compatible, but not necessarily cross-version or even cross-point-version compatible (although I haven't tested this).

Likely for that reason, LocalObject uses .wl to store objects.

Now, I can make it use .mx like so:

Block[{LocalObjects`$objectFile = "object.mx"},
   Put[1, LocalObject["test/a"]]
   ];

Block[{LocalObjects`$objectFile = "object.mx"},
 Get[LocalObject["test/a"]]
 ]

1

But this feels is unstable and hacky.

Is there a better way?

$\endgroup$
1
  • 4
    $\begingroup$ It is cross-version compatible, but only forward: later versions read earlier MX. Since some recent release, this goes both ways. Earlier M can read MX written by later M provided that no new expression types are used. However, it is not 32/64-bit cross-compatible. $\endgroup$
    – Szabolcs
    Dec 4 '17 at 10:34
3
$\begingroup$

What about Import/Export?:

Export[LocalObject["test/a"], 1, "MX"];


Import[LocalObject["test/a"], "MX"]

1

Import[LocalObject["test/a"], "Text"]

(This is a Wolfram Language binary dump file. It can be loaded with \ Get.)

...

(End of Wolfram Language binary dump file)

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.