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

Uploaded CPython 3.8+Windows x86-64

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

Uploaded CPython 3.8+Windows x86

polars_legacy_hash-0.0.4-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.4-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.4-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.4.tar.gz.

File metadata

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

File hashes

Hashes for polars_legacy_hash-0.0.4.tar.gz
Algorithm Hash digest
SHA256 af73fac0d9565015196ff6d9cc27166c2b209e50a4ed7eef998058017fef8acd
MD5 45e75c3434288109e450aec9aba55a53
BLAKE2b-256 cab922c23256aba51aaecbdb6bd757e0cd51cd682eee47e4d6f59a9f953d7779

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for polars_legacy_hash-0.0.4-cp38-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 95e4638ed0e863c7e08a59c4b90d972109937e8455b7f6c8c6731509c289d6e9
MD5 014855dd6b39b6d5c940c4caf0ea39c0
BLAKE2b-256 f06347a999d1734539e6da0434dd4ce55bcee54eb9d3c4fdb7484be2477a97df

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for polars_legacy_hash-0.0.4-cp38-abi3-win32.whl
Algorithm Hash digest
SHA256 7c75d3ac4987831a63ed5805a618abe27ecff5dc499a2171fae87e2c0e5646f3
MD5 723fa5a6b1eb2f1c5e2057b0a1453a2c
BLAKE2b-256 3f238563ab98ffc0ac852878aad4d0cbe9daac1a38501d069e4f0eec5b3342f6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for polars_legacy_hash-0.0.4-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 f96ce832e05d2641dd34be525bf727d1d4bc19ccf8c68f950d658b02ab474d31
MD5 51b13796a80e027c286b7cec41102419
BLAKE2b-256 22ead970c6aec4ac476cd8c63c84d29ffd62b9fa8040d2d198ef1269ddbb8f1a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for polars_legacy_hash-0.0.4-cp38-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 51745ad8f5f8f41ffdec3eed06c23c9433dffe5b189bcf78d4ef2beae439f5bb
MD5 c38554ed7049aff7ca82a9cb64b52011
BLAKE2b-256 091cc0108a8a7e9b1775b902e403a80fb23874d801139b481bca3fe8b01ae021

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for polars_legacy_hash-0.0.4-cp38-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 64a2786797e15f647b6e33cf63f5f46896f0d81d6b1bc1647cee994a82ecadd5
MD5 a112d038d027411449716357493bb89e
BLAKE2b-256 01b73c295ca0956dd8d67d06fd766de9dbcd9e3d65083411efcf498b887d1b94

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