Skip to main content

Optional native (Rust/PyO3) acceleration kernels for goldenflow

Project description

goldenflow-native

Optional native (Rust/PyO3) acceleration kernels for GoldenFlow. The sibling of goldenmatch-native; same abi3 / maturin / Arrow-zero-copy posture.

GoldenFlow stays a pure-Python wheel. pip install goldenflow[native] pulls this compiled runtime, and goldenflow.core._native_loader discovers it (or falls back to pure Python when it's absent). It is off by default at runtime even when installed — see Gating.

What it accelerates

The international phone family. GoldenFlow's pure-Python transforms already resolve the common (NANP) case with vectorized Polars expressions; these kernels accelerate the residual — international numbers that would otherwise hit the phonenumbers library one row at a time. Kernels:

function returns
phone_e164_arrow(array, region) Utf8 E.164 (null on parse failure)
phone_national_arrow(array, region) Utf8 national format
phone_country_code_arrow(array, region) Int64 country calling code
phone_valid_arrow(array, region) Boolean validity

Each takes an Arrow Utf8/LargeUtf8 array (zero-copy in), returns an Arrow array (zero-copy out), and releases the GIL around the compute loop. Any row it can't parse comes back null so the Python reference settles it — the native path is never worse than pure Python.

Dates are intentionally not a native kernel: the Polars str.to_date coalesce fast path already resolves the 4-digit-year formats in vectorized Rust, and a per-row chrono parser would be slower while reintroducing a 2-digit-year parity hazard. The ragged date tail stays on dateutil.

Gating: NANP-only (parity-safe, on by default)

phone is in goldenflow.core._native_loader._GATED_ON, so it runs under GOLDENFLOW_NATIVE=auto (the default) — but only in a provably parity-safe mode.

Characterization across 20 country metadata sets showed the Rust phonenumber port is byte-identical to the Python phonenumbers library except when a +CC international number is parsed with a mismatched default region (the transforms pass "US") and its national number starts with 1 (e.g. +33142685300 → native +3342685300 — the port mis-applies US national-prefix stripping). It also diverges on ambiguous leading-1 inputs (1234567890 → native +1234567890 vs python +11234567890).

Two gates make native authoritative only where it's proven correct:

  1. Kernel nanp_only mode — emits a result only for country-code-1 numbers; everything else returns null and falls back to Python.
  2. Canonical-NANP acceptance (in transforms/_native.py) — keeps only ^\+1[2-9]\d{9}$ outputs, dropping the malformed 9-digit results the leading-1 ambiguity produces.

So native resolves the canonical-NANP residual the Polars fast path can't reach (alpha like 1-800-FLOWERS, extensions, +1-prefixed forms) ~4-5× faster, and everything international/ambiguous defers to Python. phone_country_code is also gated (country code agrees on all NANP); phone_national/phone_validate stay pure Python (no cheap canonical check). Verified byte-identical to phonenumbers over a 60k mixed corpus in packages/python/goldenflow/tests/transforms/test_native_parity.py.

GOLDENFLOW_NATIVE=0 forces pure Python; =1 enables native for all components (bench/parity lane, no nanp_only restriction — will diverge on intl).

Build

# In-tree dev build (drops goldenflow/_native.abi3.so):
python packages/python/goldenflow/scripts/build_native.py

# Distributable abi3 wheel:
cd packages/rust/extensions/native-flow && maturin build --release

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

goldenflow_native-0.1.1.tar.gz (16.1 kB view details)

Uploaded Source

Built Distributions

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

goldenflow_native-0.1.1-cp311-abi3-win_amd64.whl (1.4 MB view details)

Uploaded CPython 3.11+Windows x86-64

goldenflow_native-0.1.1-cp311-abi3-manylinux_2_28_x86_64.whl (1.7 MB view details)

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

goldenflow_native-0.1.1-cp311-abi3-manylinux_2_28_aarch64.whl (1.8 MB view details)

Uploaded CPython 3.11+manylinux: glibc 2.28+ ARM64

goldenflow_native-0.1.1-cp311-abi3-macosx_11_0_arm64.whl (1.5 MB view details)

Uploaded CPython 3.11+macOS 11.0+ ARM64

goldenflow_native-0.1.1-cp311-abi3-macosx_10_12_x86_64.whl (1.6 MB view details)

Uploaded CPython 3.11+macOS 10.12+ x86-64

File details

Details for the file goldenflow_native-0.1.1.tar.gz.

File metadata

  • Download URL: goldenflow_native-0.1.1.tar.gz
  • Upload date:
  • Size: 16.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for goldenflow_native-0.1.1.tar.gz
Algorithm Hash digest
SHA256 2d6c252b57a93410d179379bcbeeb49e1d5b5b0159d179280a00a5e5a5f136ab
MD5 0653f445fbee73854e5a65ca4a1bb3ab
BLAKE2b-256 7107ca4c292f8e2989204ebb17a315063851c86f4188f6fb293b441b03b4b616

See more details on using hashes here.

File details

Details for the file goldenflow_native-0.1.1-cp311-abi3-win_amd64.whl.

File metadata

File hashes

Hashes for goldenflow_native-0.1.1-cp311-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 a3f51b9d654d3555b06397b14ed9e0aca1201c2974e791bbf718d63a0e07b8d7
MD5 f40b9247d31dbfb64198989f961547b4
BLAKE2b-256 b724e99c5a4708e90341fbb2df55f1b2191578680d22e25424b4dfec560136ce

See more details on using hashes here.

File details

Details for the file goldenflow_native-0.1.1-cp311-abi3-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for goldenflow_native-0.1.1-cp311-abi3-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 1471dfb0ae8af059309856ed22ba80e7b473c17c9e6a0bf6ad867f970bcb965f
MD5 109fbf6c112f5ded859e37cd46bdb560
BLAKE2b-256 e224c3a6ff8c520e1f15d17569bb25f6252c909534f10cf33067051258b3a68a

See more details on using hashes here.

File details

Details for the file goldenflow_native-0.1.1-cp311-abi3-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for goldenflow_native-0.1.1-cp311-abi3-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 a638fff4099775c133c865580fa6d9b2c0d9be08b52e34a0c51a4d0845cda10f
MD5 179c0b74f1dfad21a687d3718e6606e0
BLAKE2b-256 f97d44096e9654b96fb9038662a72f2cad0b0a5a272f4ed35560e76b0af9958e

See more details on using hashes here.

File details

Details for the file goldenflow_native-0.1.1-cp311-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for goldenflow_native-0.1.1-cp311-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 4886451d7f09e4f8da4a330f8f53561e0f7e57a27fa75487547557c903c2d45c
MD5 d293da0dff5223f083483b7224f1988d
BLAKE2b-256 40b14ace1800d395596751294e92dbbf1c8bb25278b1738c67c348f41056f3cf

See more details on using hashes here.

File details

Details for the file goldenflow_native-0.1.1-cp311-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for goldenflow_native-0.1.1-cp311-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 c38f657560bd0dbb4383db700d7303921c125ff7cfed092fe0fb367e527bf465
MD5 c5799762f64d79961a2da19af6d71f44
BLAKE2b-256 414ec076a8cf38e8fc30c2bb48adf609695e56cc7a82ac345e4a4054a63f4201

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