Skip to content

v0.0.8 - Vectorized urllib sync-XHR byte restore (~5x)

Choose a tag to compare

@eddmpython eddmpython released this 13 Jul 13:08

Vectorized the urllib sync-XHR response byte restore (x-user-defined text to bytes).

The old restore ran bytes(ord(c) & 0xFF for c in body), a per-character Python loop that cost seconds on MB-scale responses. It now encodes the text to UTF-16LE once (C level) and extracts the low byte of each code unit with numpy. Measured on a 12.8MB body: 1.85s to 0.38s (about 5x), byte-identical across all 256 byte values. Falls back to the old loop when numpy is unavailable.

Non-breaking: no public surface or signature change.


urllib 동기 XHR 응답 바이트 복원(x-user-defined 텍스트 to 바이트)을 벡터화. 옛 복원은 bytes(ord(c) & 0xFF for c in body) 로 문자마다 파이썬을 돌아 MB 응답에서 수 초를 먹었다. UTF-16LE 로 C 레벨 1회 인코딩한 뒤 numpy 로 하위 바이트만 벡터 추출한다. 실측 12.8MB 1.85초 to 0.38초(약 5배), byte-identical(전 256 바이트값 검증), numpy 부재 시 옛 루프로 폴백. 공개 표면·시그니처 변경 없음(비브레이킹).