René's URL Explorer Experiment


Title: Return precomputed bytes for single-byte indexed fields by DicksonWu654 · Pull Request #305 · python-hyper/hpack · GitHub

Open Graph Title: Return precomputed bytes for single-byte indexed fields by DicksonWu654 · Pull Request #305 · python-hyper/hpack

X Title: Return precomputed bytes for single-byte indexed fields by DicksonWu654 · Pull Request #305 · python-hyper/hpack

Description: Every header that is already in the static or dynamic table is encoded by Encoder._encode_indexed(), which calls encode_integer() (building a bytearray), sets the top bit and copies the result to bytes. Any index below 127 fits in the 7-bit prefix and always encodes to the single byte 0x80 | index, so this looks those up in a 127-entry tuple of precomputed bytes instead. Other values and types (127 and above, bool, negative numbers, non-ints) still go through encode_integer(), with the same output and errors. When the hpack logger has DEBUG enabled, the existing path is used as well, so the Encoding %d with %d bits records (including their funcName) are unchanged. The table adds 127 one-byte bytes objects at import time. Benchmarks Each workload runs header blocks through Encoder.encode() and, for *_roundtrip, Decoder.decode(). browser_mixed alternates 16 browser-like requests and 16 responses; repeated_requests sends one request 16 times, so after the first block every field is indexed; long_cookie is 16 requests whose cookie is about 1.2 KB; no_huffman_encode is browser_mixed with huffman=False; fixture_stories_roundtrip replays the first four stories of the hpack-test-case fixtures in tests/. master and this branch were imported side by side in the same interpreter and timed in alternating ~20 ms CPU-time blocks (40 rounds in each of 6 processes, pinned to one core). The table shows the median per-round speedup with a 95% bootstrap interval. The machine was shared with other work, so the absolute times are only indicative. Workload CPython 3.12.3 master → branch (µs) CPython 3.12.3 speedup CPython 3.14.8 speedup browser_mixed_encode 1,794.3 → 1,695.9 1.06x [1.03, 1.08] 1.06x [1.05, 1.08] browser_mixed_roundtrip 3,938.6 → 3,755.2 1.04x [1.02, 1.06] 1.02x [1.01, 1.04] repeated_requests_encode 414.7 → 337.5 1.24x [1.22, 1.26] 1.23x [1.22, 1.25] repeated_requests_roundtrip 953.5 → 872.3 1.10x [1.07, 1.13] 1.11x [1.09, 1.12] responses_decode 669.4 → 666.5 1.01x [0.99, 1.03] 1.00x [0.99, 1.02] long_cookie_encode 7,183.9 → 7,029.2 1.00x [0.99, 1.02] 1.01x [1.00, 1.02] long_cookie_roundtrip 12,117.6 → 11,750.4 1.02x [1.00, 1.03] 1.00x [0.98, 1.01] no_huffman_encode 1,028.6 → 944.7 1.10x [1.09, 1.12] 1.09x [1.07, 1.10] fixture_stories_roundtrip 2,086.2 → 1,987.1 1.06x [1.04, 1.08] 1.07x [1.05, 1.08] Behaviour New tests: the indexed encoding at the 7-bit prefix boundary (0, 1, 126, 127, 128, 255, True), invalid values, and a DEBUG-logging round trip that checks the redaction of sensitive values and that the integer-encoding records still come from encode_integer. pytest passes with 100% statement and branch coverage on CPython 3.11, 3.12, 3.13 and 3.14; ruff check src/ and mypy src/ (the lint tox env) pass. I also compared master and this branch on 1,500 random encoder/decoder sessions per interpreter (CPython 3.11 and 3.14), including repeated headers so the dynamic table is hit, table size changes, sensitive headers and direct _encode_indexed() calls with indices from 0 to 200. The encoded bytes, decoded headers, exceptions and, with DEBUG logging enabled, every log record were identical. 🤖 Generated with Claude Code

Open Graph Description: Every header that is already in the static or dynamic table is encoded by Encoder._encode_indexed(), which calls encode_integer() (building a bytearray), sets the top bit and copies the result to b...

X Description: Every header that is already in the static or dynamic table is encoded by Encoder._encode_indexed(), which calls encode_integer() (building a bytearray), sets the top bit and copies the result to b...

Opengraph URL: https://github.com/python-hyper/hpack/pull/305

X: @github

direct link

Domain: github.com

IPv4 address: 140.82.114.3

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:50d722f7-59bb-ea30-815f-c7be00057857
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idB34C:5D41F:222B352:2EB6912:6B0733DF
html-safe-noncecd438fbb2b82c7a29a7a8e8369d10c8495e319fbcfb0807685485f616e993b93
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCMzRDOjVENDFGOjIyMkIzNTI6MkVCNjkxMjo2QjA3MzNERiIsInZpc2l0b3JfaWQiOiI0ODA5MTEyMDM0NTkzOTQ0NTQ0IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmac8662b951ae1b17e481e79e04a12ecfd7ad64f8a7874a0f4d5333064574d4bf36
hovercard-subject-tagpull_request:5185682259
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/files
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/python-hyper/hpack/pull/305/files
twitter:imagehttps://avatars.githubusercontent.com/u/33645481?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/33645481?s=400&v=4
og:image:altEvery header that is already in the static or dynamic table is encoded by Encoder._encode_indexed(), which calls encode_integer() (building a bytearray), sets the top bit and copies the result to b...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
None2a60952cad7efb2604ea85e500208f51c1ec1943aa260ac605c13eb46a1ed83b
turbo-cache-controlno-preview
diff-viewunified
go-importgithub.com/python-hyper/hpack git https://github.com/python-hyper/hpack.git
octolytics-dimension-user_id13035907
octolytics-dimension-user_loginpython-hyper
octolytics-dimension-repository_id33873218
octolytics-dimension-repository_nwopython-hyper/hpack
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id33873218
octolytics-dimension-repository_network_root_nwopython-hyper/hpack
turbo-body-classeslogged-out env-production page-responsive full-width
disable-turbotrue
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release345c27626db08417fdfc84278a4415ae9a48d8f3
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/python-hyper/hpack/pull/305/files#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython-hyper%2Fhpack%2Fpull%2F305%2Ffiles
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython-hyper%2Fhpack%2Fpull%2F305%2Ffiles
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fpull_requests%2Fshow%2Ffiles&source=header-repo&source_repo=python-hyper%2Fhpack
Reloadhttps://github.com/python-hyper/hpack/pull/305/files
Reloadhttps://github.com/python-hyper/hpack/pull/305/files
Reloadhttps://github.com/python-hyper/hpack/pull/305/files
python-hyperhttps://github.com/python-hyper
hpackhttps://github.com/python-hyper/hpack
Codehttps://github.com/python-hyper/hpack
Issueshttps://github.com/python-hyper/hpack/issues
Pull requests7 (7)https://github.com/python-hyper/hpack/pulls
Actionshttps://github.com/python-hyper/hpack/actions
Security and quality1 (1)https://github.com/python-hyper/hpack/security
Insightshttps://github.com/python-hyper/hpack/insights
Sign up for GitHub https://github.com/signup?return_to=%2Fpython-hyper%2Fhpack%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://github.com/login?return_to=%2Fpython-hyper%2Fhpack%2Fissues%2Fnew%2Fchoose
DicksonWu654https://github.com/DicksonWu654
python-hyper:masterhttps://github.com/python-hyper/hpack/tree/master
DicksonWu654:perf/indexed-field-byteshttps://github.com/DicksonWu654/hpack/tree/perf/indexed-field-bytes
Conversation 0 https://github.com/python-hyper/hpack/pull/305
Commits 1 https://github.com/python-hyper/hpack/pull/305/commits
Checks 0 https://github.com/python-hyper/hpack/pull/305/checks
Files changed https://github.com/python-hyper/hpack/pull/305/files
Please reload this pagehttps://github.com/python-hyper/hpack/pull/305/files
Return precomputed bytes for single-byte indexed fields https://github.com/python-hyper/hpack/pull/305/files#top
Show all changes 1 commit https://github.com/python-hyper/hpack/pull/305/files
f6b554d Return precomputed bytes for single-byte indexed fields DicksonWu654 Nov 6, 2026 https://github.com/python-hyper/hpack/pull/305/commits/f6b554de435a27aa2a083cc11602c4fdbe6fae15
Clear filters https://github.com/python-hyper/hpack/pull/305/files
Please reload this pagehttps://github.com/python-hyper/hpack/pull/305/files
Please reload this pagehttps://github.com/python-hyper/hpack/pull/305/files
CHANGELOG.rst https://github.com/python-hyper/hpack/pull/305/files#diff-2c623f3c6a917be56c59d43279244996836262cb1e12d9d0786c9c49eef6b43c
hpack.py https://github.com/python-hyper/hpack/pull/305/files#diff-311bdeef42d63e07b32935c24dc7c3e0f57f90ea54b357673d0fa0a7d8a23b5e
test_hpack.py https://github.com/python-hyper/hpack/pull/305/files#diff-dc78395f3ddc698fad2eec94932df306aa317f3901921ce52c033cd2c6d6d6a0
CHANGELOG.rsthttps://github.com/python-hyper/hpack/pull/305/files#diff-2c623f3c6a917be56c59d43279244996836262cb1e12d9d0786c9c49eef6b43c
View file https://github.com/python-hyper/hpack/blob/f6b554de435a27aa2a083cc11602c4fdbe6fae15/CHANGELOG.rst
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python-hyper/hpack/pull/305/{{ revealButtonHref }}
https://github.com/python-hyper/hpack/pull/305/files#diff-2c623f3c6a917be56c59d43279244996836262cb1e12d9d0786c9c49eef6b43c
https://github.com/python-hyper/hpack/pull/305/files#diff-2c623f3c6a917be56c59d43279244996836262cb1e12d9d0786c9c49eef6b43c
src/hpack/hpack.pyhttps://github.com/python-hyper/hpack/pull/305/files#diff-311bdeef42d63e07b32935c24dc7c3e0f57f90ea54b357673d0fa0a7d8a23b5e
View file https://github.com/python-hyper/hpack/blob/f6b554de435a27aa2a083cc11602c4fdbe6fae15/src/hpack/hpack.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python-hyper/hpack/pull/305/{{ revealButtonHref }}
https://github.com/python-hyper/hpack/pull/305/files#diff-311bdeef42d63e07b32935c24dc7c3e0f57f90ea54b357673d0fa0a7d8a23b5e
https://github.com/python-hyper/hpack/pull/305/files#diff-311bdeef42d63e07b32935c24dc7c3e0f57f90ea54b357673d0fa0a7d8a23b5e
https://github.com/python-hyper/hpack/pull/305/files#diff-311bdeef42d63e07b32935c24dc7c3e0f57f90ea54b357673d0fa0a7d8a23b5e
https://github.com/python-hyper/hpack/pull/305/files#diff-311bdeef42d63e07b32935c24dc7c3e0f57f90ea54b357673d0fa0a7d8a23b5e
tests/test_hpack.pyhttps://github.com/python-hyper/hpack/pull/305/files#diff-dc78395f3ddc698fad2eec94932df306aa317f3901921ce52c033cd2c6d6d6a0
View file https://github.com/python-hyper/hpack/blob/f6b554de435a27aa2a083cc11602c4fdbe6fae15/tests/test_hpack.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python-hyper/hpack/pull/305/{{ revealButtonHref }}
https://github.com/python-hyper/hpack/pull/305/files#diff-dc78395f3ddc698fad2eec94932df306aa317f3901921ce52c033cd2c6d6d6a0
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Response headers:
Servergithub.com
Content-Typetext/html; charset=utf-8
Cache-Controlno-cache

Viewport: width=device-width


URLs of crawlers that visited me.