Skip to main content

A Python library for Apache Arrow

Project description

arrowmodel

PyPI Python License

Dict-free, single-step conversion from Apache Arrow buffers to Pydantic v2 model instances.

arrowmodel uses a Rust core (via PyO3) to walk Arrow RecordBatch and Table buffers directly, building Pydantic model instances in a tight loop with no intermediate Python dicts. It replaces the to_pylist() + Model(**row) two-step with a single call that is roughly 2x faster for flat schemas.

Full Documentation

Quick Start

Installation

pip install arrowmodel

No Rust toolchain needed -- pre-built wheels are provided.

First Use

import pyarrow as pa
from arrowmodel import ArrowModel


class User(ArrowModel):
    id: int
    name: str
    score: float


batch = pa.record_batch(
    {
        "id": [1, 2, 3],
        "name": ["Alice", "Bob", "Carol"],
        "score": [9.5, 8.0, 7.3],
    }
)

users = User.convert(batch)
# [User(id=1, name='Alice', score=9.5), ...]

Key Features

  • Dict-free conversion: Arrow buffers go straight to model_construct calls in Rust -- no to_pylist(), no intermediate dicts.
  • ~2x faster for flat schemas: Roughly twice the throughput of the pure-Python approach, with less allocation pressure.
  • Three API styles: ArrowModel base class for concise models, ArrowModelConverter for reusable converters, and model_convert/model_iter for one-shot use.
  • Validated mode: Pass validate=True to run full Pydantic validation (model_validate_json) when you need type coercion or custom validators.
  • Pydantic alias support: Resolves validation_alias, alias, field name, and populate_by_name / validate_by_name.
  • Nested models: Arrow Struct columns map to nested Pydantic models, including optional structs and deeply nested hierarchies.
  • Lazy iteration: iter() yields one model at a time, materialising one RecordBatch worth of instances in memory.
  • Broad type coverage: Integers, floats, decimals, booleans, strings, dates, timestamps, durations, times, binary, lists, structs, maps, dictionaries, unions, intervals, and more.

Input Compatibility

arrowmodel accepts any Arrow-PyCapsule-compatible input via the Arrow C Data Interface:

  • pyarrow -- RecordBatch, Table
  • Polars -- DataFrame (exports via PyCapsule)
  • nanoarrow -- arrays and record batches

No pyarrow dependency is required at runtime. If your Arrow data comes from Polars or nanoarrow, it works without installing pyarrow.

License

Apache-2.0

Project details


Download files

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

Source Distribution

arrowmodel-1.0.0.tar.gz (29.5 kB view details)

Uploaded Source

Built Distributions

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

arrowmodel-1.0.0-cp311-abi3-win_amd64.whl (2.6 MB view details)

Uploaded CPython 3.11+Windows x86-64

arrowmodel-1.0.0-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.1 MB view details)

Uploaded CPython 3.11+manylinux: glibc 2.17+ x86-64

arrowmodel-1.0.0-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (3.0 MB view details)

Uploaded CPython 3.11+manylinux: glibc 2.17+ ARM64

arrowmodel-1.0.0-cp311-abi3-macosx_11_0_arm64.whl (2.6 MB view details)

Uploaded CPython 3.11+macOS 11.0+ ARM64

arrowmodel-1.0.0-cp311-abi3-macosx_10_12_x86_64.whl (2.8 MB view details)

Uploaded CPython 3.11+macOS 10.12+ x86-64

File details

Details for the file arrowmodel-1.0.0.tar.gz.

File metadata

  • Download URL: arrowmodel-1.0.0.tar.gz
  • Upload date:
  • Size: 29.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for arrowmodel-1.0.0.tar.gz
Algorithm Hash digest
SHA256 8b1cb9a7d319fc70ba14f00b88851d12a1be16589e62c9d7ef45be8aadcb69fc
MD5 420edd0d16d30f1e612f68811ca49ad6
BLAKE2b-256 e0fea8e05b5171b50f5d81386ef42109dfecd26bb75fac33b8c5d98c1fe03c1c

See more details on using hashes here.

Provenance

The following attestation bundles were made for arrowmodel-1.0.0.tar.gz:

Publisher: release.yml on anentropic/arrowmodel

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file arrowmodel-1.0.0-cp311-abi3-win_amd64.whl.

File metadata

  • Download URL: arrowmodel-1.0.0-cp311-abi3-win_amd64.whl
  • Upload date:
  • Size: 2.6 MB
  • Tags: CPython 3.11+, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for arrowmodel-1.0.0-cp311-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 6903dc17a2b30b6c97631580c9b255953dc40f7f6d7fc88c16e07e874980ed51
MD5 e5c9c85a3b78d04db1c7247786edea8e
BLAKE2b-256 25209e6bd7485f07d3095727c1eced1c216157a3dd591d8e25e1ac6bfd0d6fa6

See more details on using hashes here.

Provenance

The following attestation bundles were made for arrowmodel-1.0.0-cp311-abi3-win_amd64.whl:

Publisher: release.yml on anentropic/arrowmodel

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file arrowmodel-1.0.0-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for arrowmodel-1.0.0-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 47c482283f07b52fb7bbf80526650e2f8bebb776c961b4754e5ecc51353c3351
MD5 d9bb61acdda0075afeb0182ab08f20af
BLAKE2b-256 5fe693ebd343deb3e52eb0281875d07745c10a9c85d61dab481559e68e6b3fb2

See more details on using hashes here.

Provenance

The following attestation bundles were made for arrowmodel-1.0.0-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: release.yml on anentropic/arrowmodel

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file arrowmodel-1.0.0-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for arrowmodel-1.0.0-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 6a86b4fac72ff72e6209b42d35cec933841389e7810014f0071c2d8a936769d7
MD5 d940cb090eab1f40640d9d2af307ec21
BLAKE2b-256 a283b926c06157c2cfcf802626a8cd6690cb2b2c886b749bf303a6388caf5a54

See more details on using hashes here.

Provenance

The following attestation bundles were made for arrowmodel-1.0.0-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: release.yml on anentropic/arrowmodel

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file arrowmodel-1.0.0-cp311-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for arrowmodel-1.0.0-cp311-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c545b52a4b701537f3a3d3aaa72e01898d22a752440747a83433a827a2ed7131
MD5 5bffdc3bf105aca488e326d09fe67cdf
BLAKE2b-256 2ad26e7947fbedf1023aab67afdeb7e5fdb086aed04cff54b0429bf6b6100536

See more details on using hashes here.

Provenance

The following attestation bundles were made for arrowmodel-1.0.0-cp311-abi3-macosx_11_0_arm64.whl:

Publisher: release.yml on anentropic/arrowmodel

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file arrowmodel-1.0.0-cp311-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for arrowmodel-1.0.0-cp311-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 f640d629e26c01a867817c4d7bab455225767c626b509880cfe95bbe1b633138
MD5 09dd162e3422b9f2b781a39c98e276c7
BLAKE2b-256 69abe0983bb4f627b0f9a761f16e025ba64dea2c1d3bf553677a6005ac572f6f

See more details on using hashes here.

Provenance

The following attestation bundles were made for arrowmodel-1.0.0-cp311-abi3-macosx_10_12_x86_64.whl:

Publisher: release.yml on anentropic/arrowmodel

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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