Skip to content

Commit e643fb8

Browse files
gpsheadclaude
andcommitted
pystrhex: Lower SIMD separator threshold to 8 bytes
Lower the threshold from abs_bytes_per_sep >= 16 to >= 8 for the SIMD hexlify + memmove shuffle path. Benchmarks show this is worthwhile for sep=8 and above, but memmove overhead negates benefits for smaller values. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 2fe987c commit e643fb8

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

Python/pystrhex.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,11 +185,11 @@ static PyObject *_Py_strhex_impl(const char* argbuf, const Py_ssize_t arglen,
185185
unsigned int k;
186186

187187
#if PY_HEXLIFY_CAN_COMPILE_SIMD
188-
/* SIMD path for large separator groups (>= 16 bytes per group).
188+
/* SIMD path for separator groups >= 8 bytes.
189189
SIMD hexlify to output buffer, then shuffle in-place to insert
190190
separators. Working backwards avoids overlap issues since we're
191191
expanding (destination index >= source index). */
192-
if (abs_bytes_per_sep >= 16 && arglen >= 16) {
192+
if (abs_bytes_per_sep >= 8 && arglen >= 16) {
193193
/* SIMD hexlify all bytes to start of output buffer */
194194
_Py_hexlify_simd((const unsigned char *)argbuf, retbuf, arglen);
195195

0 commit comments

Comments
 (0)