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
[mypyc] Add primitive for int to ascii conversion (#21036)
Added a primitive to convert `int`s into `bytes` objects suitable for
bytes format strings, eg. `b'%d' % my_int`. Works the same as the
existing `CPyTagged_Str` primitive used for formatting `str` objects,
except it returns a `bytes` object instead of `str`.
Currently only the bare `%d` specifier is supported, other integer
specifiers and `%d` with options go through the regular CPython handling
of format strings.
Results in around 23% reduced runtime in this microbenchmark:
```python
import time
t0 = time.time()
for i in range(10_000_000):
val = b'%d' % i
print(time.time() - t0)
```
Results:
| setup | runtime (s) |
| - | - |
| interpreted | 0.90 |
| mypyc master | 0.92 |
| mypyc PR | 0.69 |
0 commit comments