WOLFRAM

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 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

Examples

open allclose all

Basic Examples  (4)Summary of the most common use cases

Export an expression to WXF:

Out[1]=1

Export a string to WXF:

Out[1]=1

Export a symbolic expression to WXF:

Out[1]=1

Import as an expression:

Out[2]=2

Export an arbitrary Wolfram Language expression to the WXF format:

Import as an expression:

Out[2]=2

Scope  (2)Survey of the scope of standard use cases

Serialize an expression to a WXF byte array:

Out[1]=1

Deserialize the output using BinaryDeserialize:

Out[2]=2

Serialize an expression to a WXF byte array:

Out[1]=1

Import it using automatic format detection:

Out[2]=2

Import Elements  (4)

List available elements:

Out[1]=1

Serialize an unevaluated expression:

Out[1]=1

Import it using the default element "Expression":

Out[2]=2

Import it in a held form using the element "HeldExpression":

Out[3]=3

Get WXF data from an untrusted source:

Inspect the element "HeldExpression":

Out[2]=2

The code is safe; evaluate it:

Out[3]=3

Import bytes with the element "ExprStruct":

Out[1]=1

The expression is held in an unevaluated state:

Out[2]=2

Export Options  (5)

PerformanceGoal  (2)

Serialize an expression using BinarySerialize to produce a compressed output:

Out[1]=1

Import the resulting byte array:

Out[2]=2

Serialize a dataset:

Serialize the same dataset with PerformanceGoal set to "Size":

Compute the size of the outputs:

Out[3]=3

Both represent the same expression:

Out[4]=4

Method  (3)

By default, the WXF serialization of packed arrays of integers uses the smallest integer type that fits the data:

Out[1]=1

Export a packed array using a bigger integer type:

Out[2]=2

Create a packed array of real values:

Out[1]=1

By default, the WXF serialization of a packed array of real values uses machine doubles:

Out[2]=2

Export the array using machine floats:

Out[3]=3

Create a packed array of complex values:

Out[1]=1

By default, the WXF serialization of packed array of complex values uses two machine doubles to represent one complex value:

Out[2]=2

Export the array using lower precision:

Out[3]=3

Properties & Relations  (2)Properties of the function, and connections to other functions

ExportByteArray[expr,"WXF"] is effectively equivalent to BinarySerialize[expr]:

Out[1]=1

ImportByteArray[ba,"WXF"] is effectively equivalent to BinaryDeserialize[ba]:

Out[2]=2