Skip to content

Commit 306b868

Browse files
authored
Release 5.0.9 (#20)
* 🔧 update CI to drop non official Python setup CPython 3.13t available without workaround * ⚡ release the GIL in hpack encode/decode for the optimized build only * 🔖 bump version to 5.0.9 * 📝 write changelog for 5.0.9 * 🎨 reformat file lib.rs * 🔧 fix 3.13t x86 build
2 parents eb768d8 + 0fb68e0 commit 306b868

File tree

6 files changed

+50
-63
lines changed

6 files changed

+50
-63
lines changed

.github/workflows/CI.yml

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -138,13 +138,8 @@ jobs:
138138
steps:
139139
- uses: actions/checkout@v4
140140
- uses: actions/setup-python@v5
141-
if: matrix.python_version != '3.13t'
142141
with:
143142
python-version: ${{ matrix.python_version }}
144-
- uses: Quansight-Labs/setup-python@v5
145-
if: matrix.python_version == '3.13t'
146-
with:
147-
python-version: 3.13t
148143
- name: Build wheels
149144
uses: PyO3/maturin-action@v1
150145
env:
@@ -193,23 +188,16 @@ jobs:
193188
python_version: 'pypy-3.10'
194189
- target: x86
195190
python_version: 'pypy-3.11'
196-
- target: x86
197-
python_version: '3.13t'
198191
steps:
199192
- uses: actions/checkout@v4
200193
- uses: actions/setup-python@v5
201-
if: matrix.python_version != '3.13t'
194+
if: matrix.target != 'aarch64' # solely rely on python3-ddl generator for aarch64
202195
with:
203196
python-version: ${{ matrix.python_version }}
204-
architecture: ${{ matrix.target == 'x86' && 'x86' || 'x64' }}
205-
- uses: Quansight-Labs/setup-python@v5
206-
if: matrix.python_version == '3.13t' && matrix.target == 'x64'
207-
with:
208-
python-version: '3.13t'
209-
architecture: x64
197+
architecture: ${{ matrix.target }}
210198
- name: Build wheels (normal)
211199
uses: PyO3/maturin-action@v1
212-
if: matrix.python_version != '3.13t' || matrix.target == 'x64'
200+
if: matrix.python_version != '3.13t' || matrix.target != 'aarch64'
213201
env:
214202
UNSAFE_PYO3_SKIP_VERSION_CHECK: 1
215203
with:
@@ -245,13 +233,8 @@ jobs:
245233
steps:
246234
- uses: actions/checkout@v4
247235
- uses: actions/setup-python@v5
248-
if: matrix.python_version != '3.13t'
249236
with:
250237
python-version: ${{ matrix.python_version }}
251-
- uses: Quansight-Labs/setup-python@v5
252-
if: matrix.python_version == '3.13t'
253-
with:
254-
python-version: 3.13t
255238
- name: Build wheels
256239
uses: PyO3/maturin-action@v1
257240
env:

CHANGELOG.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
Release History
22
===============
33

4+
5.0.9 (2025-04-21)
5+
------------------
6+
7+
- Release the GIL during hpack encoding/decoding in the optimized build.
8+
- (rust) Upgrade pyo3 to 0.24.1
9+
410
5.0.8 (2025-03-06)
511
------------------
612

Cargo.lock

Lines changed: 13 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "jh2"
3-
version = "5.0.8"
3+
version = "5.0.9"
44
edition = "2021"
55

66
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

jh2/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@
77

88
from __future__ import annotations
99

10-
__version__ = "5.0.8"
10+
__version__ = "5.0.9"

src/lib.rs

Lines changed: 26 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ impl Encoder {
3030
pub fn encode<'a>(
3131
&mut self,
3232
py: Python<'a>,
33-
headers: Vec<(Bound<'_, PyBytes>, Bound<'_, PyBytes>, bool)>,
33+
headers: Vec<(Vec<u8>, Vec<u8>, bool)>,
3434
huffman: Option<bool>,
3535
) -> PyResult<Bound<'a, PyBytes>> {
3636
let mut flags = InternalEncoder::BEST_FORMAT;
@@ -41,27 +41,29 @@ impl Encoder {
4141

4242
let mut dst = Vec::new();
4343

44-
for (header, value, sensitive) in headers.iter() {
45-
let mut header_flags: u8 = flags;
44+
let encode_res = py.allow_threads(|| {
45+
for (header, value, sensitive) in headers.iter() {
46+
let mut header_flags: u8 = flags;
4647

47-
if *sensitive {
48-
header_flags |= InternalEncoder::NEVER_INDEXED;
49-
} else {
50-
header_flags |= InternalEncoder::WITH_INDEXING;
51-
}
48+
if *sensitive {
49+
header_flags |= InternalEncoder::NEVER_INDEXED;
50+
} else {
51+
header_flags |= InternalEncoder::WITH_INDEXING;
52+
}
5253

53-
let enc_res = self.inner.encode(
54-
(
55-
header.as_bytes().to_vec(),
56-
value.as_bytes().to_vec(),
57-
header_flags,
58-
),
59-
&mut dst,
60-
);
54+
let enc_res = self
55+
.inner
56+
.encode((header.to_vec(), value.to_vec(), header_flags), &mut dst);
6157

62-
if enc_res.is_err() {
63-
return Err(HPACKError::new_err("operation failed"));
58+
if enc_res.is_err() {
59+
return Err(HPACKError::new_err("operation failed"));
60+
}
6461
}
62+
Ok(())
63+
});
64+
65+
if encode_res.is_err() {
66+
return Err(encode_res.err().unwrap());
6567
}
6668

6769
Ok(PyBytes::new(py, dst.as_slice()))
@@ -71,7 +73,7 @@ impl Encoder {
7173
pub fn add<'a>(
7274
&mut self,
7375
py: Python<'a>,
74-
header: (Bound<'_, PyBytes>, Bound<'_, PyBytes>),
76+
header: (Vec<u8>, Vec<u8>),
7577
sensitive: bool,
7678
huffman: Option<bool>,
7779
) -> PyResult<Bound<'a, PyBytes>> {
@@ -89,14 +91,10 @@ impl Encoder {
8991

9092
let mut dst = Vec::new();
9193

92-
let enc_res = self.inner.encode(
93-
(
94-
header.0.as_bytes().to_vec(),
95-
header.1.as_bytes().to_vec(),
96-
flags,
97-
),
98-
&mut dst,
99-
);
94+
let enc_res = py.allow_threads(|| {
95+
self.inner
96+
.encode((header.0.to_vec(), header.1.to_vec(), flags), &mut dst)
97+
});
10098

10199
if enc_res.is_err() {
102100
return Err(HPACKError::new_err("operation failed"));
@@ -159,7 +157,7 @@ impl Decoder {
159157

160158
let mut data = Vec::with_capacity(1);
161159

162-
let dec_res = self.inner.decode_exact(&mut buf, &mut data);
160+
let dec_res = py.allow_threads(|| self.inner.decode_exact(&mut buf, &mut data));
163161

164162
if dec_res.is_err() {
165163
return Err(HPACKError::new_err("operation failed"));

0 commit comments

Comments
 (0)