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.3.tar.gz (36.8 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.3-cp38-abi3-win_amd64.whl (3.7 MB view details)

Uploaded CPython 3.8+Windows x86-64

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

Uploaded CPython 3.8+Windows x86

polars_legacy_hash-0.0.3-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.3-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.3-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.3.tar.gz.

File metadata

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

File hashes

Hashes for polars_legacy_hash-0.0.3.tar.gz
Algorithm Hash digest
SHA256 2ce418ffa3313d1b09419de96b2ee5102f5fdd4e099523acf7140ff8ada69ada
MD5 0baa943330de05f493aeec266cf68acd
BLAKE2b-256 c3fdcb93c8e946e962fda3e16da251a82394e5a62fdf3f598f3719f2aff2eb78

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for polars_legacy_hash-0.0.3-cp38-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 74e122ccb20b961842d4d7976ac1ca37ea6ce4b8174e78e5e1fed4e403f839f3
MD5 92d6a8f785a8533552798b86df41df5e
BLAKE2b-256 fd6d7db73b64bf5e8344a18b96a38e9ac423c53ca0b921bb580ed33bab639ee7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for polars_legacy_hash-0.0.3-cp38-abi3-win32.whl
Algorithm Hash digest
SHA256 dfdaff59ca18c114fbe3f11c0579c00159819a4f841ce99bd68866d974b352e9
MD5 e9e9338b07b18127fd0b4d4f777f1526
BLAKE2b-256 b39a8f3d5ee9d95ff0b82c2d39860b10dde0a5893bf54ab217b828e0f0a0a0a8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for polars_legacy_hash-0.0.3-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 d799fd396455a74380fa51ac8d8a5b07f16e6c467a73313dd498bb011c18b484
MD5 cd39e6788b06c0fc637a71d4a35010f9
BLAKE2b-256 9470ef2204672a5f82c8257de38c261ac92e5fbe0e07bdb89a36365303bbbfa2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for polars_legacy_hash-0.0.3-cp38-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 fea68a21204eb66916ab27e07aaade5847d1a6542168a498418ed7feb5783617
MD5 544431d6b202b87d6366f24035d366f8
BLAKE2b-256 3936771fb4db3570bd3bcde33511e01fae77c59a1516a8484e6a108847272a4b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for polars_legacy_hash-0.0.3-cp38-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 f6a006b24631af8791fb66fbb0a621372da516c205d61ab00190dcc9882daa7c
MD5 8df47b3d3f367d3eeae21149267f61af
BLAKE2b-256 273c00559f23e88e3278016dfaf1015530eaff21076a54a11be91a656d17d354

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