SMILE Format
Description
SMILE (Smile is a Machine-Interchangeable Language for Everything) is a binary data format similar to JSON but more compact. It was developed by the Jackson JSON library team and provides efficient binary serialization of JSON-like data structures.
File Extensions
.smile- SMILE format files
Implementation Details
Reading
The SMILE implementation:
- Imports
smilewhen installed (there is no PyPI extra; see Limitations) - Reads binary SMILE data
- Supports single documents or arrays
- Converts SMILE data to Python objects
Writing
Writing support:
- Encodes Python objects to SMILE format
- Writes binary SMILE data
- Supports nested structures
Key Features
- Binary format: More compact than JSON
- JSON-compatible: Same data structures as JSON
- Nested data: Supports complex nested structures
- Type preservation: Maintains data types
Usage
from iterable import open_iterable
# Basic reading
with open_iterable('data.smile') as source:
for row in source:
print(row)
# Writing
with open_iterable('output.smile', mode='w') as dest:
dest.write({'name': 'John', 'age': 30})
Parameters
No specific parameters required.
Limitations
- Not on PyPI: There is no
iterabledataextra for SMILE. The reader importssmileand the ImportError namessmile-json, which is not a pip-installable package today. - Binary format: Not human-readable
- Memory usage: Entire file may be loaded into memory
- Less common: Not as widely used as JSON or MessagePack
Compression Support
SMILE files can be compressed with all supported codecs:
- GZip (
.smile.gz) - BZip2 (
.smile.bz2) - LZMA (
.smile.xz) - LZ4 (
.smile.lz4) - ZIP (
.smile.zip) - Brotli (
.smile.br) - ZStandard (
.smile.zst)
Use Cases
- Binary JSON: When JSON is too verbose
- Data storage: Efficient binary storage
- Jackson integration: Working with Jackson-based systems
Error Handling
- Missing dependency: optional libraries raise
ImportErrorwith an install hint (pip install 'iterabledata[<extra>]'when an extra exists). - Write mode: read-only formats raise
WriteNotSupportedErrororValueErrorwhen opened withmode="w". - Bad or unsupported input: may raise
ValueError,OSError, or library-specific errors. - See Troubleshooting for decoding, detection, and engine issues.
Related Formats
- JSON - Text-based format
- MessagePack - Similar binary format
- CBOR - Another binary format