Commit e8973a0
committed
perf: avoid unnecessary dict allocation in execute_async custom_payload
Remove the unconditional empty dict allocation on the hot path of
execute_async(). Previously, every call allocated {} even when no
custom_payload or execute_as was provided (>99% of calls). The empty
dict was passed to update_custom_payload() which short-circuited on
'if other:' since {} is falsy.
Now custom_payload remains None by default and a dict is only allocated
when execute_as is truthy (the rare DSE proxy-execute case).
update_custom_payload(None) correctly short-circuits at 'if other:'.
Benchmark (5M calls, common case - no payload, no execute_as):
Before: 280 ns/call
After: 88 ns/call
Speedup: 3.19x1 parent 8e6c4d4 commit e8973a0
1 file changed
Lines changed: 1870 additions & 750 deletions
0 commit comments