Skip to main content

avroc

avroc is a Python just-in-time compiler for reading and writing Avro data.

It aims to be:

  • Completely correct to the Avro specification.
  • Very, very fast when compiled. Our goal is to be the fastest library available in Python for dealing with Avro.
  • Ergonomic and simple to use, with a small API that's clear.

Installation

Install with pip:

pip install avroc

Basic usage

import avroc

# Make up a schema
schema = {
    "type": "record",
    "name": "Weather",
    "fields": [
        {"name": "temperature", "type": "double"},
        {"name": "wind_speed", "type": "double"},
        {"name": "location", "type": "string"},
    ]
}

# Make up some records
records = [
    {"temperature": 71.2, "wind_speed": 0.5, "location": "San Diego"},
    {"temperature": 8.2, "wind_speed": 13.4, "location": "North Pole"},
    {"temperature": -66.0, "wind_speed": 14.4, "location": "Mars"},
]

# Write records to a file
with open("data.avro, "wb") as f:
    avroc.write_file(f, schema, records)

# Read records from a file
with open("data.avro", "rb") as f:
    for msg in avroc.read_file(f):
        print(f'The temperature in {msg["location"]} is {msg["temperature"]}')

# Encode a single record as raw bytes
encoder = avroc.compile_encoder(schema)
raw_bytes = encoder(records[0])

# Decode a raw bytes as a single record
decoder = avroc.compile_decoder(schema)
rec = decoder(io.BytesIO(raw_bytes))

For a lot more detail, see the documentation: avroc.readthedocs.io

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

avroc-0.3.1.tar.gz (30.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

avroc-0.3.1-py3-none-any.whl (38.4 kB view details)

Uploaded Python 3

File details

Details for the file avroc-0.3.1.tar.gz.

File metadata

  • Download URL: avroc-0.3.1.tar.gz
  • Upload date:
  • Size: 30.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.8.10

File hashes

Hashes for avroc-0.3.1.tar.gz
Algorithm Hash digest
SHA256 fe90bb2ad877573b47da56b54850ebd7253c39e1ce13cd2b36392c1bd9fcda83
MD5 261149db448149263a03ccf601cff885
BLAKE2b-256 d9fd1699b453b0e748f718c1796190ecd85f22522a134a21c18a494ecf686f19

See more details on using hashes here.

File details

Details for the file avroc-0.3.1-py3-none-any.whl.

File metadata

  • Download URL: avroc-0.3.1-py3-none-any.whl
  • Upload date:
  • Size: 38.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.8.10

File hashes

Hashes for avroc-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 4300a760eb465610d1a818937fd2fa71fdd34cdd0979eb1cca036e52cd657757
MD5 ab29ce5553b9abfddbe9c1461f01671e
BLAKE2b-256 7c5642544d2f0a059bac46faa31ad026aa53dd526a179bc9c1e60f1add45ea6a

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.3.1 This release

2 files

0.3.0

2 files

0.2.2

2 files

0.2.1

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page