MX (.mx)
Background & Context

-
- Wolfram Language serialized package format.
- Used for the distribution of Wolfram Language packages.
- Stores arbitrary Wolfram Language expressions in a serialized format optimized for fast loading.
- Binary file format.
- MX files cannot be exchanged between operating systems that differ in $SystemWordLength.
- MX files created by newer versions of the Wolfram System may not be usable by older versions.
- Developed by Wolfram Research.
Import & Export

- Import["file.mx"] reads in an MX file and returns an expression.
- Export["file.mx",expr] serializes an arbitrary Wolfram Language expression and saves it as an MX file.
- Import["file.mx",elem] imports the specified element from an MX file.
- The import format can be specified with Import["file","MX"] or Import["file",{"MX",elem,…}].
- Import["file.mx"] is equivalent to Get["file.mx"].
- See the following reference pages for full general information:
-
Import, Export import from or export to a file CloudImport, CloudExport import from or export to a cloud object ImportString, ExportString import from or export to a string ImportByteArray, ExportByteArray import from or export to a byte array
Import Elements

- General Import elements:
-
"Elements" list of elements and options available in this file "Summary" summary of the file "Rules" list of rules for all available elements - Import elements:
-
"Expression" reads and evaluates all expressions, returning the last one "HeldExpression" list of unevaluated expressions "ExprStruct" returns the result as an "ExprStruct" data structure - Import by default uses the "Expression" element for Wolfram Language MX files.
Examples
Basic Examples (2)Summary of the most common use cases
Export an arbitrary Wolfram Language expression to the MX format:
In[1]:=1

✖
https://wolfram.com/xid/0u0xcxs-ver9ze
Out[1]=1

In[2]:=2

✖
https://wolfram.com/xid/0u0xcxs-30i6zg
Show the available Import elements:
In[3]:=3

✖
https://wolfram.com/xid/0u0xcxs-iyv1xw
Out[3]=3

In[4]:=4

✖
https://wolfram.com/xid/0u0xcxs-57uxsr
Out[4]=4

Import of "MX" format using an "ExprStruct" element creates an "ExprStruct" data structure:
In[1]:=1

✖
https://wolfram.com/xid/0u0xcxs-2iyvxe
Out[1]=1

Return the original expression:
In[2]:=2

✖
https://wolfram.com/xid/0u0xcxs-s7a1wa
Out[2]=2
