Initializing help system before first use

to_binary

Purpose
Convert a Python dictionary to Mosel binary format bytes.
Synopsis
function to_binary(data) -> bytes
Argument
data 
Dictionary with string keys and values convertible to Mosel types
Return value
Binary data as a bytes object
Example
Create binary data for a Mosel model:
data = {"x": 42, "arr": {1: 10, 2: 20}}
bin_data = mp.to_binary(data)
output = model.run(input_data={"mydata": bin_data})
Further information
1. The binary format is the same as used by Mosel's bin: driver. In the Mosel model, use initializations from "bin:moselpy:name" to read the binary data.
2. Binary format is more efficient than text format for large datasets and preserves full precision for floating-point numbers.
Related topics
Module
moselpy

© 2001-2026 Fair Isaac Corporation. All rights reserved. This documentation is the property of Fair Isaac Corporation (“FICO”). Receipt or possession of this documentation does not convey rights to disclose, reproduce, make derivative works, use, or allow others to use it except solely for internal evaluation purposes to determine whether to purchase a license to the software described in this documentation, or as otherwise set forth in a written software license agreement between you and FICO (or a FICO affiliate). Use of this documentation and the software described in it must conform strictly to the foregoing permitted uses, and no other use is permitted.