Skip to main content
File added late

1 file was added to this release more than 14 days after its initial publication. Inspect the release files before installing.

Spavro Build

(Sp)eedier Avro - Spavro

Spavro is a fork of the official Apache AVRO python 2 implementation with the goal of greatly improving data read deserialization and write serialization performance.

Spavro is also python 2/3 compatible (instead of a separate project / implementation). Currently tested using python 2.7, 3.3, 3.4, 3.5, 3.6, 3.7, 3.8, 3.9, 3.10, and 3.11. Python 3 versions before 3.3 are not supported due to the use of unicode literals and other compatibility features.

Implementation Details

There are three primary differences between the official implementation and Spavro. First, Spavro uses a C extension, created with Cython, to accelerate some of the low level binary serialization logic. Additionally Spavro uses a different model for handling schemas. Spavro attempts to parse the write and read schemas once and only once and creates recursive reader/writer functions from the schema definition. These reader/writer functions encode the type structure of the schema so no additional lookups are necessary while processing data. The last difference is that Spavro has been updated to be both Python 2 and Python 3 compatible using the six library. The official apache AVRO implementation has two separate codebases for Python 2 and Python 3 and spavro only has one.

This has the net effect of greatly improving the throughput of reading and writing individual datums, since the schema isn't interrogated for every datum. This can be especially beneficial for "compatible" schema reading where both a read and write schema are needed to be able to read a complete data set.

Performance / Benchmarks

Results

These tests were run using an AWS m4.large instance running CentOS 7. They were run with the following versions: avro-python3==1.8.2, fastavro==0.17.9, spavro==1.1.10. Python 3.6.4 was used for the python 3 tests.

The TLDR is that spavro has 14-23x the throughput of the default Apache avro implementation and 2-4x the throughput of the fastavro library (depending on the shape of the records).

Deserialize avro records (read)

Records per second read:

Read, 1 field, records per sec Read, 500 fields, records per sec

Datums per second (individual fields) read:

Read, fields per second

Serialize avro records (write)

Records per second write:

Write, 1 field, records per sec Write, 500 fields, records per sec

Datums per second (individual fields) write:

Write, fields per second

Methodology

Benchmarks were performed with the benchmark.py script in the /benchmarks path in the repository (if you'd like to run your own tests).

Many of the records that led to the creation of spavro were of the form {"type": "record", "name": "somerecord", "fields": [1 ... n fields usually with a type of the form of a union of ['null' and a primitive type]]} so the benchmarks were created to simulate that type of record structure. I believe this is a very common use case for avro so the benchmarks were created around this pattern.

The benchmark creates a random schema of a record with a mix of string, double, long and boolean types and a random record generator to test that schema. The pseudo-random generator is seeded with the same string to make the results deterministic (but with varied records). The number of fields in the record was varied from one to 500 and the performance of the avro implementations were tested for each of the cases.

The serializer and deserializer benchmarks create an array of simulated records in memory and then attempts to process them using the three different implementation as quickly as possible. This means the max working size is limited to memory (a combination of the number of records and the number of fields in the simulated record). For these benchmarks 5m datums were processed for each run (divided by the number of fields in each record).

Each run of the schema/record/implementation was repeated ten times and the time to complete was averaged.

API

Spavro keeps the default Apache library's API. This allows spavro to be a drop-in replacement for code using the existing Apache implementation.

Tests

Since the API matches the existing library, the majority of the existing Apache test suite is used to verify the correct operation of Spavro. Spavro adds some additional correctness tests to compare new vs old behaviors as well as some additional logic tests above and beyond the original library. Some of the java-based "map reduce" tests (specifically the tether tests) were removed because Spavro does not include the java code to implement that logic.

Release files for spavro 1.1.27

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

File added late

1 file was uploaded more than 14 days after the first file in this release.

While project maintainers occasionally add legitimate files to an existing release, late additions can also indicate a security compromise.

We recommend inspecting the release files before installing.

Source distribution (sdist)

Source distribution for spavro 1.1.27
File Size Uploaded
spavro-1.1.27.tar.gz 250.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for spavro 1.1.27
File Interpreter ABI Platform
spavro-1.1.27-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.whl CPython 3.11 CPython 3.11 Linux glibc 2.17+ ARM64 Details

Total release size: 1.1 MB

Release files / spavro-1.1.27.tar.gz

Download URL spavro-1.1.27.tar.gz
Size 250.3 kB
Tags Source
SHA-256 checksum
How to use checksums
77a800153f7db2181a0fbd7f1b2b23fec1436c67b5cd4e982b39911693f96cad
BLAKE2b-256 checksum
How to use checksums
d3b404097fbed1c26d2c43f8b90dcad9bd5190ab5928826620df679e7eea849c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.6

Release files / spavro-1.1.27-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.whl

File added late

This file was uploaded more than 14 days after the first file in this release.

While project maintainers occasionally add legitimate files to an existing release, late additions can also indicate a security compromise.

We recommend inspecting the release file before installing.

Download URL spavro-1.1.27-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Size 854.3 kB
Tags CPython 3.11 Linux glibc 2.17+ ARM64
SHA-256 checksum
How to use checksums
2a187e751212fc77091214d565e620413da191a3318b1a14a995e1d51303cf8b
BLAKE2b-256 checksum
How to use checksums
dfc7011f5f11aad1f9df55db9bafa3c984cf111e7702a04df812db70d59cfb1f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.13

Release history Release notifications | RSS feed

This release

1.1.27 This release

2 release files

1.1.26

1 release file

1.1.24

1 release file

1.1.23

1 release file

1.1.22

1 release file

1.1.21

1 release file

1.1.20

1 release file

1.1.19

1 release file

1.1.18

1 release file

1.1.17

1 release file

1.1.16

1 release file

1.1.15

1 release file

1.1.14

1 release file

1.1.13

1 release file

1.1.12

1 release file

1.1.11

1 release file

1.1.10

1 release file

1.1.9

1 release file

1.1.8

1 release file

1.1.7

1 release file

1.1.6

1 release file

1.1.5

1 release file

1.1.4

1 release file

1.1.3

1 release file

1.1.2

1 release file

1.1.1

1 release file

1.1.0

1 release file

1.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page