← Back to Pull requests

Use zstandard implementation from stdlib (PEP-784) #3725

Open
Rogdham opened this pull request with 40 lines diff across 5 files
View on GitHub
Rogdham Rogdham commented on Dec 13, 2025 16:14 UTC
Author

<!-- Thanks for contributing to HTTPX! 💚
Given this is a project maintained by volunteers, please read this template to not waste your time, or ours! 😁 -->

Summary

Context

Thanks to PEP-784, Zstandard is included in Python starting from version 3.14 with the compression.zstd module.

So for Python 3.14+, we don't need an external lib. For older version of Python, I'm using backports.zstd which exposes the same API as stdlib.

This also means that users of Python 3.14+ will benefit from Zstandard support even if they install httpx instead of httpx[zstd].

A similar change has been adopted in various other libraries already, such as urllib3 from version 2.6.0.

_Full disclosure: I'm the author and maintainer of backports.zstd, and the maintainer of pyzstd (which code was used as a base for the integration into Python). I also helped with PEP-784 and its integration into CPython._

Checklist

  • I understand that this PR may be closed in case there was no previous discussion. (This doesn't apply to typos!)

  • I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change.

  • I've updated the documentation accordingly.
  • Diff: 40 lines (+24 / -16) across 5 files Reviewer: mbeijen Review duration: 458774m
    All Vouch review confidence checks passed
    Residual risk 0.12 = Change Risk (0.38) × (1 − Review Confidence (0.68)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.38 · 40 lines diff across 5 files
    0.38
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.54 · 2 substantive comment(s)
    0.54
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    68%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.222
    Real PR Conversation Timeline
    4 items
    Rogdham Rogdham commented on Dec 13, 2025 16:25 UTC
    Author

    Hello @mbeijen, as the author of Zstandard support in httpx your review would be appreciated! :hugs:

    mbeijen mbeijen commented on Dec 15, 2025 08:29 UTC
    Contributor

    Thanks for your work, this looks great (esp. together with #3726 !!!)

    mbeijen mbeijen approved these changes on Dec 15, 2025 08:29 UTC
    Approved Reviewer

    Approved these changes.

    Reviewers
    Assignees
    Rogdham Rogdham
    Labels
    risk: low confidence: 68.1% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 38.1% (MEDIUM) · Higher = larger blast radius
    38.1%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 68.1% · Lower = rushed or shallow review
    68.1%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 12.1% · Safe to merge
    12.1%
    Repository