10000 GitHub - chip44/zarr-python-39: Backport of Zarr for Python 3.9 compatibility
[go: up one dir, main page]

Skip to content

chip44/zarr-python-39

 
 

Repository files navigation

Zarr (Python 3.9 Backport)

Building

  1. Clone this repository:

    git clone https://github.com/chip44/zarr-python-39.git
    cd zarr-python-39
  2. Set up virtual environment:

    python -m venv venv
    source venv/bin/activate
    pip install hatch
  3. Build the package:

    hatch build

Code Changes

Syntax

  • Converted all match-case statements to if-else blocks (only appeared in test files)
  • Replaced star-unpacking in indices (arr[*selection]) with explicit tuple conversion (arr[tuple(selection)]) (only appeared in test files)
  • Reordered class fields to follow Python 3.9's requirement (non-default fields must precede fields with defaults) (might cause breakage?)

Types

  • Converted union type operators (|) to Union[] declarations (only in type declarations, since type hints in methods/classes are not checked at runtime)
  • Replaced isinstance() union checks (|) with tuple-based checks
  • Added from __future__ import annotations to all files using type hints
  • Replaced typing imports with typing_extensions for modern type hints (e.g. Self, TypeAlias)

Polyfills

  • zip(strict=True): Implemented a custom wrapper (_compat.py) and imported globally
  • @dataclass(kw_only=True): Implemented a custom wrapper (_compat.py) and imported globally
  • itertools.pairwise(): Implemented an equivalent replacement (single occurrence)
  • importlib.metadata: Replaced with importlib_metadata (also added as a dependency)

Configuration Changes

  • Set minimum Python version to 3.9 in pyproject.toml
  • Renamed package to zarr-py39
  • Bundled numcodecs dependency (for simplified maintenance):
    • Includes all compatibility modifications listed above
    • Note: Since numcodecs contains C extensions, the zarr-py39 wheel must be compiled per Python version (e.g., cp39 Python 3.9 wheel), unlike the original py3 generic wheel

About

Backport of Zarr for Python 3.9 compatibility

Resources

License

Stars

Watchers

Forks

Languages

  • C 65.4%
  • Python 20.4%
  • C++ 8.1%
  • Ada 1.2%
  • Cython 0.8%
  • Makefile 0.7%
  • Other 3.4%
0