Skip to content

Commit

Permalink
Merge pull request #2 from jawah/fix-perf-regression
Browse files Browse the repository at this point in the history
⚡ Fix a minor performance regression when building headers frame
  • Loading branch information
Ousret authored Apr 28, 2024
2 parents a25df36 + cd2573e commit 3647680
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 18 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
Release History
===============

5.0.1 (2024-04-28)
------------------

- Fixed a minor performance regression in ``_build_headers_frames`` method.
- (Rust) Bump pyo3 to version 0.20.3

5.0.0 (2024-04-28)
------------------

Expand Down
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "jh2"
version = "5.0.0"
version = "5.0.1"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
Expand All @@ -9,7 +9,7 @@ name = "jh2"
crate-type = ["cdylib"]

[dependencies]
pyo3 = { version = "0.20.2", features = ["abi3-py37"] }
pyo3 = { version = "0.20.3", features = ["abi3-py37"] }
httlib-hpack = { version = "0.1.3" }

[package.metadata.maturin]
Expand Down
2 changes: 1 addition & 1 deletion jh2/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@

from __future__ import annotations

__version__ = "5.0.0"
__version__ = "5.0.1"
24 changes: 10 additions & 14 deletions jh2/stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -1351,20 +1351,16 @@ def _build_headers_frames(
headers = validate_outbound_headers(headers, hdr_validation_flags)

if ALTERNATIVE_HPACK:
buf = []

for header in headers:
h, v = header

if isinstance(h, str):
h = h.encode()
if isinstance(v, str):
v = v.encode()
is_sensitive = isinstance(header, NeverIndexedHeaderTuple)

buf.append((h, v, is_sensitive))

encoded_headers = encoder.encode(buf)
encoded_headers = encoder.encode(
[
(
h[0] if isinstance(h[0], bytes) else h[0].encode(),
h[1] if isinstance(h[1], bytes) else h[1].encode(),
isinstance(h, NeverIndexedHeaderTuple),
)
for h in headers
]
)
else:
encoded_headers = encoder.encode(headers)

Expand Down

0 comments on commit 3647680

Please sign in to comment.