You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
method.upper() recomputed multiple times per attempt inside the request retry loop #342
SyncTransport.request and AsyncTransport.request call method.upper() repeatedly inside the retry loop — once for the auth-sign, once for the httpx call, once inside sign_request itself, plus inside every debug log statement, multiplied across retry attempts and across both transports. Same string allocated each time for lowercase input. Cost per call is microseconds, but #262 specifically hoisted invariant header merging out of the retry loop for the same reason; this is the same pattern still latent.
Evidence
kalshi/_base_client.py:286-303 — multiple .upper() calls per attempt in the sync loop
kalshi/_base_client.py:504-535 — identical shape in AsyncTransport.request.
kalshi/auth.py:276 — sign_request also does method.upper() internally
message=ts_str+method.upper() +clean_path
Suggested fix
Normalize once at the top of request(): method = method.upper(). Reuse the normalized variable for the auth sign, httpx call, all log statements, and the retry-budget logs. Drop the redundant method.upper() inside sign_request (transports are now the only callers and always pre-normalize). Mirror the change in AsyncTransport.request and KalshiAuth.sign_request_async. Signing payload is byte-identical for any caller that passed lowercase.
Activity
polish(transport): async close cancellation-safe + _delete_with_body …