WXF (.wxf)
- Import and Export fully support Wolfram Language WXF files.
- WXF byte arrays can be created with BinarySerialize and read with BinaryDeserialize.
Background & Context
-
- Wolfram exchange format.
- Binary format.
- Represents arbitrary Wolfram Language expressions in a serialized, platform-independent form.
- Versioned format.
- Developed in 2017 by Wolfram Research.
Import & Export
- Import["file.wxf"] imports a WXF file as a Wolfram Language expression.
- ImportString["string","WXF"] imports a WXF string of bytes.
- ImportByteArray[bytearray, "WXF"] imports a WXF array of bytes.
- Export["file.wxf",expr] exports the binary representation of an expr to a WXF file.
- 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" returns the serialized expression "HeldExpression" returns the expression wrapped in HoldComplete "ExprStruct" returns the expression as an "ExprStruct" data structure - Import by default uses the "Expression" element for Wolfram Language WXF files.
Options
- Export options:
-
PerformanceGoal Automatic specify a serialization strategy Method Automatic serialization method options
Examples
open allclose allBasic Examples (4)
Scope (2)
Serialize an expression to a WXF byte array:
Deserialize the output using BinaryDeserialize:
Import Elements (4)
Export Options (5)
PerformanceGoal (2)
Serialize an expression using BinarySerialize to produce a compressed output:
Import the resulting byte array:
Serialize the same dataset with PerformanceGoal set to "Size":
Method (3)
By default, the WXF serialization of packed arrays of integers uses the smallest integer type that fits the data:
Export a packed array using a bigger integer type:
Create a packed array of real values:
By default, the WXF serialization of a packed array of real values uses machine doubles:
Export the array using machine floats:
Create a packed array of complex values:
By default, the WXF serialization of packed array of complex values uses two machine doubles to represent one complex value:
Properties & Relations (2)
ExportByteArray[expr,"WXF"] is effectively equivalent to BinarySerialize[expr]:
ImportByteArray[ba,"WXF"] is effectively equivalent to BinaryDeserialize[ba]: