Skip to content

Add optional native parser backend (minimal adapter) - #1

Closed
lowmiaq-gmail wants to merge 2 commits into
masterfrom
codex/semver-native-adapter-20260828
Closed

lowmiaq-gmail wants to merge 2 commits into
masterfrom
codex/semver-native-adapter-20260828

Conversation

@lowmiaq-gmail

Copy link
Copy Markdown
Owner

Fixes python-semver#474

Summary

This PR implements the minimal adapter for an optional native parser backend as proposed in python-semver#474. The implementation is intentionally small to minimize maintenance footprint:

  • 3 files changed, 41 lines added
  • Pure Python remains the default — no changes to existing behavior
  • Native backend is opt-in via pip install python-semver[native]
  • Backend package (fast-semver-rs-backend) is maintained separately by the contributor
  • Automatic fallback to Python parser when backend is unavailable or encounters bounded integer limits

Changes

  1. pyproject.toml: Add [project.optional-dependencies] with native extra pointing to fast-semver-rs-backend>=0.1.1 (CPython only)
  2. src/semver/version.py: Optional import of native backend; use it in Version.parse() only when:
    • Backend is present
    • Not using optional_minor_and_patch mode (Python-only feature)
    • Backend doesn't raise ValueError (falls through to Python for unbounded integers)
  3. tests/test_optional_native_backend.py: Tests for backend presence and fallback behavior

Compatibility

  • ✅ All 41 existing parsing tests pass
  • ✅ Backend test skips gracefully when not installed
  • ✅ No breaking changes to public API
  • ✅ PyPy and other implementations continue using pure Python path

Maintenance model

  • python-semver maintains only the thin adapter (this PR)
  • Backend wheels, implementation, and CI are maintained separately by the contributor
  • No packaging overhead for core maintainers
  • Decoupled release cycles

Verification

Per python-semver#474:

  • Official test suite: 342 passed with backend, 341 passed + 1 skipped without
  • 10,000-case differential corpus: 0 mismatches
  • Backend CI: 10/10 jobs passed across Linux, macOS, Windows (x86_64/arm64) on CPython 3.10–3.14

Reviewer guidance

@tomschr: This PR focuses exclusively on the maintenance footprint of the adapter itself. The backend implementation, wheels, and benchmarks are provided as context in python-semver#474 but are not part of this review scope. Please evaluate:

  1. Whether the 41-line adapter is acceptable maintenance overhead
  2. The optional-dependency model and fallback behavior
  3. Any concerns about the integration points

Performance evidence and detailed backend verification are documented in the original issue.

Open in Web Open in Cursor 

edgarrmondragon and others added 2 commits August 31, 2026 23:02
@lowmiaq-gmail

Copy link
Copy Markdown
Owner Author

Opened against the fork by mistake. Upstream PR: python-semver#476

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Proposal: optional native parser backend with pure-Python fallback

2 participants