-
-
Notifications
You must be signed in to change notification settings - Fork 33.3k
gh-139156: Use PyBytesWriter in PyUnicode_EncodeCodePage() #139259
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Replace PyBytes_FromStringAndSize() and _PyBytes_Resize() with the PyBytesWriter API.
|
Benchmark: import pyperf
runner = pyperf.Runner()
for size in (3, 100, 1000):
runner.timeit(f'{size:,} ASCII chars',
setup=f's="x"*{size}',
stmt='s.encode("mbcs")')
for size in (3, 100, 1000):
runner.timeit(f'{size:,} UCS-2 chars',
setup=f's="€"*{size}',
stmt='s.encode("mbcs")')Results on Windows on a release build:
Benchmark hidden because not significant (2): 100 ASCII chars, 1,000 UCS-2 chars |
|
Replace PyBytes_FromStringAndSize() and _PyBytes_Resize() with the PyBytesWriter API.