Skip to main content

Polars 0.20.10 hash function as a plugin library

Project description

Polars legacy hash

For a specific project, I needed to preserve the hashing behaviour of polars 0.20.10 (or the underlying ahash 0.8.7), whilst also wanting to upgrade polars itself.

For now this plugin specifically caters to 0.20.10, but in principle could be generalised. See also Polars Hash which is a more general solution to this, which is coupled to a specific point in time in the history of polars. If there ever comes a use case for this, I expect to move to some version of versioning akin to stub libraries e.g. 0.20.10.20250415 and deploy these from seperate branches to avoid having to bundle multiple polars binaries into the same wheel.

Installation

pip install polars_legacy_hash in your virtualenv. Note that you'll need to install polars seperately. This package doesn't depend on polars explicitly, so that if you use e.g. polars-u64-idx we won't pull in polars as well (TODO double check this works as intended)

Usage

The best way to explain what this package does it to demonstrate:

# /// script
# requires-python = ">=3.8"
# dependencies = [
#     "polars==0.20.10",
#     "polars_legacy_hash",
# ]
# ///
import polars as pl

import polars_legacy_hash as plh

print(f"Hashing with polars={pl.__version__} directly:")
s = pl.Series([42])
print(s.hash().item())
print("Using polars_legacy_hash:")
result = s.to_frame("test").select(plh.legacy_hash(pl.col("test"))).to_series()
print(result.item())

Running this with uv run --script examples/polars_0.20.10.py produces this:

Hashing with polars=0.20.10 directly:
3146795401079207122
Using polars_legacy_hash:
3146795401079207122

Running the analogous uv run --script examples/polars_1.27.1.py we get:

Hashing with polars=1.27.1 directly (not consistent!):
16588070273457376249
Using polars_legacy_hash:
3146795401079207122

i.e. we get the same consistent output, in spite of the polars version change.

For correctness checking, the CI runs test_expectations.py under polars 0.20.10 to confirm that the test values in the fixtures (defined in tests/conftest.py) are consistent with polars itself from that version.

Known limitations

  • No support for polars categorical

Development

The plugin is built with maturin, and uv is setup to rebuild an editable install whenever the rust part of the plugin changes. This means the simplest way to run the tests is uv run pytest -rP

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

polars_legacy_hash-0.0.5.tar.gz (36.4 kB view details)

Uploaded Source

Built Distributions

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

polars_legacy_hash-0.0.5-cp38-abi3-win_amd64.whl (3.7 MB view details)

Uploaded CPython 3.8+Windows x86-64

polars_legacy_hash-0.0.5-cp38-abi3-win32.whl (3.2 MB view details)

Uploaded CPython 3.8+Windows x86

polars_legacy_hash-0.0.5-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (4.7 MB view details)

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

polars_legacy_hash-0.0.5-cp38-abi3-macosx_11_0_arm64.whl (3.9 MB view details)

Uploaded CPython 3.8+macOS 11.0+ ARM64

polars_legacy_hash-0.0.5-cp38-abi3-macosx_10_12_x86_64.whl (4.3 MB view details)

Uploaded CPython 3.8+macOS 10.12+ x86-64

File details

Details for the file polars_legacy_hash-0.0.5.tar.gz.

File metadata

  • Download URL: polars_legacy_hash-0.0.5.tar.gz
  • Upload date:
  • Size: 36.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.8.3

File hashes

Hashes for polars_legacy_hash-0.0.5.tar.gz
Algorithm Hash digest
SHA256 dfc0795b9c9045b4ced005bcfb13536e52f960d2f4ce82a5d312c26150d37816
MD5 9d74aa5b34e236f9d88ebf42e0bd8dc3
BLAKE2b-256 5fb82451b8ba068d4094637f7a7027e2cf6166f03ccf7baca461be3584f01759

See more details on using hashes here.

File details

Details for the file polars_legacy_hash-0.0.5-cp38-abi3-win_amd64.whl.

File metadata

File hashes

Hashes for polars_legacy_hash-0.0.5-cp38-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 e0ed1d85b4534a6b00e821a8574137dc566f21c0a949fd15db1751bc9f3588f7
MD5 91b9ebd1ccb1f0353edbb986d31270a0
BLAKE2b-256 82c83726df10b628e9ca78d5c42938d75fa55c4f9154be97a8479b39e1147207

See more details on using hashes here.

File details

Details for the file polars_legacy_hash-0.0.5-cp38-abi3-win32.whl.

File metadata

File hashes

Hashes for polars_legacy_hash-0.0.5-cp38-abi3-win32.whl
Algorithm Hash digest
SHA256 5ae5520f6bc2dde82f934cf60bd5d996c4639e9c502d524f916ddd5d407c3b1d
MD5 8be24127cb6e576de1a02fc5bc639b27
BLAKE2b-256 22ad7bbffc585d4eb6f687ca9bf74aa8dcada250907e6ff2d0137306e8f5096b

See more details on using hashes here.

File details

Details for the file polars_legacy_hash-0.0.5-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for polars_legacy_hash-0.0.5-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 63da3f67be4e5f13feb63aa663a3d26675d970b9f423e1ff8f48532d30256f39
MD5 cee5249b45711324e57d4b399cde93f7
BLAKE2b-256 440684ec79337841ace7266012dd5773e2d1ab21be30fc82926b9a9f221691c3

See more details on using hashes here.

File details

Details for the file polars_legacy_hash-0.0.5-cp38-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for polars_legacy_hash-0.0.5-cp38-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 26f165aaf083d58154915fdfb6a41440b23b55c950619d02422ae641013e6745
MD5 ba78c8cb3d4f37dd90c9355732f10383
BLAKE2b-256 959c3d63f77f5bf5be23392605c555c4bd6730ca93b176888397f49edfea077f

See more details on using hashes here.

File details

Details for the file polars_legacy_hash-0.0.5-cp38-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for polars_legacy_hash-0.0.5-cp38-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 3543849c1c32a4241c214983a21b43327b19ae83acc38afcc289d1198cbb4b41
MD5 97dc967157d3cb6d9406dc08b60e07e7
BLAKE2b-256 314e37dcd3cbb14d1718e918d11935878b34645e34bbbea980105777e693c3b4

See more details on using hashes here.

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