Latest Results
Replace switch(algo) dispatch with function-pointer table for stateful methods
Define XXH_AlgoDispatch (create_state, free_state, reset, update,
digest, intdigest, copy_state) and a const XXH_DISPATCH[] array
indexed by XXH_Algo, eliminating all 10 switch(self->algo) statements
in the stateful path (_xxhash_init_state, _xxhash_free_state,
_xxhash_reset_state, _xxhash_do_update, _xxhash_new, XXHASH_init,
XXHASH_digest, XXHASH_hexdigest, XXHASH_intdigest, XXHASH_copy).
Also remove the unused _free_module callback (PyType_FromModuleAndSpec
ties heap type lifetime to the module automatically).
Benchmarks show performance at parity or slightly improved
(constructor+hexdigest ~6-20% faster). refactor: merge 4 C types into single XXHASHObject type
Following CPython _hashlib's pattern (one HASH type for all algorithms),
merge the four per-algorithm C types (PYXXH32Object, PYXXH64Object,
PYXXH3_64Object, PYXXH3_128Object) into a single XXHASHObject type.
Key changes:
- Single struct with XXH_Algo enum + union of state pointers
- Single set of tp_* methods with algo-based dispatch (switch)
- Single methods/getseters/slots/spec (was 4 copies of each)
- 4 module-level constructor functions (xxh32, xxh64, xxh3_64, xxh3_128)
sharing a single _xxhash_new helper
- One-shot functions consolidated via DEFINE_ONESHOT macro
- PyCFunction constructors replace 4 separate type objects
- Updated .pyi stubs: constructors are functions, not @final classes
Results:
- C source reduced by 37% (2271 -> 1421 lines, -845 lines)
- Zero warnings on all supported Python versions (3.9-3.15, 3.14t)
- All 124 tests pass across all versions Latest Branches
0%
dependabot/github_actions/pypa/cibuildwheel-4.0.0 0%
dependabot/github_actions/astral-sh/setup-uv-8.2.0 0%
© 2026 CodSpeed Technology