Skip to main content

Row-level, type-preserving encode/decode for Polars columns

Project description

pl-row-encode

A Polars plugin for row-level, type-preserving encode/decode.

encode(*cols) packs a set of columns into a single Binary column where each value is an opaque, self-describing token: the polars-row encoding of the row, prefixed with an embedded schema header. decode_series(...) reverses it back into a Struct, recovering the original dtypes without needing any external schema.

DataFrame
  -> encode(*cols)
  -> opaque bytes
  -> decode(...)   # (row bytes -> Struct -> original typed columns)
  -> DataFrame

The type information rides with the token and can be decoded on the spot at some later date.

Token layout

Each Binary value is:

[ u32 header_len (LE) ][ header bytes ][ row bytes ]

header is a bincode-serialized Vec<Field> (logical schema); row bytes is the unordered polars-row encoding of that single row. Embedding the header per value makes every token independently decodable.

Usage

import polars as pl
from pl_row_encode import encode, decode_series

df = pl.DataFrame({"id": [1, 2], "name": ["alice", "bob"]})

tokens = df.select(tok=encode("id", "name"))["tok"]   # dtype: Binary
# ... hand `tokens` to a vendor, get them back ...

decoded = decode_series(tokens).struct.unnest()        # back to id / name with dtypes

For the lazy engine, the output Struct dtype must be known up front, so pass a token's header explicitly:

from pl_row_encode import decode
header = ...  # the [u32 len][header] prefix of any token
lf.select(decode("tok", schema_header=header)).collect()

Development

make develop   # build the Rust extension into the venv (uv run maturin develop)
make test      # build + run pytest
make lint      # ruff + ty

The first make develop compiles the full Polars Rust workspace and takes a few minutes; subsequent builds are incremental and fast.

Notes / limitations

  • Built on polars-row, the same machinery Polars uses internally for sort/group-by row encoding — lossless for primitive, string, boolean, temporal, and nested types.
  • decode_series infers the schema from the first non-null token, so an all-null/empty Series needs the explicit decode(schema_header=...) form.

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

pl_row_encode-0.3.1.tar.gz (44.2 kB view details)

Uploaded Source

Built Distributions

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

pl_row_encode-0.3.1-cp313-cp313t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (6.7 MB view details)

Uploaded CPython 3.13tmanylinux: glibc 2.17+ x86-64

pl_row_encode-0.3.1-cp313-cp313t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (5.7 MB view details)

Uploaded CPython 3.13tmanylinux: glibc 2.17+ ARM64

pl_row_encode-0.3.1-cp313-cp313t-macosx_11_0_arm64.whl (5.5 MB view details)

Uploaded CPython 3.13tmacOS 11.0+ ARM64

pl_row_encode-0.3.1-cp313-cp313t-macosx_10_12_x86_64.whl (6.1 MB view details)

Uploaded CPython 3.13tmacOS 10.12+ x86-64

pl_row_encode-0.3.1-cp39-abi3-win_amd64.whl (6.9 MB view details)

Uploaded CPython 3.9+Windows x86-64

pl_row_encode-0.3.1-cp39-abi3-musllinux_1_2_x86_64.whl (6.7 MB view details)

Uploaded CPython 3.9+musllinux: musl 1.2+ x86-64

pl_row_encode-0.3.1-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (6.7 MB view details)

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

pl_row_encode-0.3.1-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (5.8 MB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ ARM64

pl_row_encode-0.3.1-cp39-abi3-macosx_11_0_arm64.whl (5.5 MB view details)

Uploaded CPython 3.9+macOS 11.0+ ARM64

pl_row_encode-0.3.1-cp39-abi3-macosx_10_12_x86_64.whl (6.1 MB view details)

Uploaded CPython 3.9+macOS 10.12+ x86-64

File details

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

File metadata

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

File hashes

Hashes for pl_row_encode-0.3.1.tar.gz
Algorithm Hash digest
SHA256 9bbe883ebb4d0abdf6d12014d95774da2e05238905ff14177b1421b09b9c1492
MD5 09f74e41c9f6c044697e52183215648d
BLAKE2b-256 5abb11296554fdbd48a5a859ca373a0ed4e6c82baea0324957b1eaa48d654308

See more details on using hashes here.

Provenance

The following attestation bundles were made for pl_row_encode-0.3.1.tar.gz:

Publisher: release-please.yml on tylerriccio33/pl-row-encode

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

File details

Details for the file pl_row_encode-0.3.1-cp313-cp313t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pl_row_encode-0.3.1-cp313-cp313t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 f311fefbef6260391ae09c8af05a84b40d13730e35df2cad7162df410f5b6b0b
MD5 9577cc90f08f8630893153392b4c5431
BLAKE2b-256 9c7ad37dcdf60c3b37340c90beb09c038555088cc1facea2559b3fc21adbe501

See more details on using hashes here.

Provenance

The following attestation bundles were made for pl_row_encode-0.3.1-cp313-cp313t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: release-please.yml on tylerriccio33/pl-row-encode

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

File details

Details for the file pl_row_encode-0.3.1-cp313-cp313t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for pl_row_encode-0.3.1-cp313-cp313t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 4c5b7cc05410a6d9c07f448ad60c63e8caabfbc56cf2713c0a812ea396578f17
MD5 4457a1a50b94434fbd2a4908b6a6ecb7
BLAKE2b-256 562880aae20aeac46a0697d5e8caf9df1c78438e26d7ef87bc9820f29cd9e024

See more details on using hashes here.

Provenance

The following attestation bundles were made for pl_row_encode-0.3.1-cp313-cp313t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: release-please.yml on tylerriccio33/pl-row-encode

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

File details

Details for the file pl_row_encode-0.3.1-cp313-cp313t-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pl_row_encode-0.3.1-cp313-cp313t-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 dcfb97d469c90da2fe7a2b4c7a12ba95c9a9de9ec905031051c4bcb4844bb5ba
MD5 8d2eecdc96ab6996554909d3b25b1632
BLAKE2b-256 bbcc2e52d213be11d8c0e760b30269419c9b8ca37945ca6f90e08bb6f7504e55

See more details on using hashes here.

Provenance

The following attestation bundles were made for pl_row_encode-0.3.1-cp313-cp313t-macosx_11_0_arm64.whl:

Publisher: release-please.yml on tylerriccio33/pl-row-encode

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

File details

Details for the file pl_row_encode-0.3.1-cp313-cp313t-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for pl_row_encode-0.3.1-cp313-cp313t-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 db38fb37c32c58d34a140a1d30e8d8bf1266c2bb21a99bbb8ab7951b4bec147a
MD5 037597bb62e84cd0cda0f65c01c90148
BLAKE2b-256 1a0396de8ed0c5a645d51e67aa6f5f0e1e2aee1887b4e34312743b1f0fe20c6f

See more details on using hashes here.

Provenance

The following attestation bundles were made for pl_row_encode-0.3.1-cp313-cp313t-macosx_10_12_x86_64.whl:

Publisher: release-please.yml on tylerriccio33/pl-row-encode

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

File details

Details for the file pl_row_encode-0.3.1-cp39-abi3-win_amd64.whl.

File metadata

File hashes

Hashes for pl_row_encode-0.3.1-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 0f81681eded79243ae92e236a8d23cbef5f323e8dc899c0a94725c7dba45398f
MD5 5b82959393de95af7ef104023a1c8e59
BLAKE2b-256 08781e01b95c7a85a44773ecee583ef41f6a65ef1211889107c86d1b4df07d60

See more details on using hashes here.

Provenance

The following attestation bundles were made for pl_row_encode-0.3.1-cp39-abi3-win_amd64.whl:

Publisher: release-please.yml on tylerriccio33/pl-row-encode

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

File details

Details for the file pl_row_encode-0.3.1-cp39-abi3-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for pl_row_encode-0.3.1-cp39-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 9329132f15655be3c2bab388356aa5ca0715e64516a25648ebdeb5dacd226b63
MD5 59d2aa5c550baf0c2b62b5601e6d6cae
BLAKE2b-256 7456ffea5e2f4a9d484245d181363ff71a8771a6ef7759329a43a19bb5f37342

See more details on using hashes here.

Provenance

The following attestation bundles were made for pl_row_encode-0.3.1-cp39-abi3-musllinux_1_2_x86_64.whl:

Publisher: release-please.yml on tylerriccio33/pl-row-encode

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

File details

Details for the file pl_row_encode-0.3.1-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pl_row_encode-0.3.1-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 92dfc9f68dfa618e2e568b8d234b08c9e7b6964d0b74f170618d5a780d388301
MD5 f47eb9d6299930107598e1e0cec20181
BLAKE2b-256 18ee17924a0215cab1a489693b4cb72226cce0ac2fb15ac2545aa756113bf7d9

See more details on using hashes here.

Provenance

The following attestation bundles were made for pl_row_encode-0.3.1-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: release-please.yml on tylerriccio33/pl-row-encode

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

File details

Details for the file pl_row_encode-0.3.1-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for pl_row_encode-0.3.1-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 91806d3faa82f93a843ca26d9ece68a593b69cd583466b34f4296a5a58f810fb
MD5 4e1ab0c711bf360e9e0aaca8bcd2369d
BLAKE2b-256 16099c8b003fcab92e30030b17f162095e34a031ca62ca1bb1691aed311758d7

See more details on using hashes here.

Provenance

The following attestation bundles were made for pl_row_encode-0.3.1-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: release-please.yml on tylerriccio33/pl-row-encode

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

File details

Details for the file pl_row_encode-0.3.1-cp39-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pl_row_encode-0.3.1-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 adfbf5c85cdf569608f6946668033ddb0f55ea237c1a9dcac30e19a622b65c03
MD5 1548bf2c3aab87df9230193c0c59d38c
BLAKE2b-256 fa130e0a7bdcf507497c0d0f167f7e8d8cdd835cdac4d90b99ca56635e7d0356

See more details on using hashes here.

Provenance

The following attestation bundles were made for pl_row_encode-0.3.1-cp39-abi3-macosx_11_0_arm64.whl:

Publisher: release-please.yml on tylerriccio33/pl-row-encode

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

File details

Details for the file pl_row_encode-0.3.1-cp39-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for pl_row_encode-0.3.1-cp39-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 4dff93dac209a73eacc191e801d45002c99abffde3eca977e48b609a726dd09f
MD5 f32d2317fc1f01b193db619b333b2310
BLAKE2b-256 0296b512af5af9d44f246739ab24b1ba42a5f4a653309a33c8b553377e59d46a

See more details on using hashes here.

Provenance

The following attestation bundles were made for pl_row_encode-0.3.1-cp39-abi3-macosx_10_12_x86_64.whl:

Publisher: release-please.yml on tylerriccio33/pl-row-encode

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