Visitar URL original
Issue 46993: Speed up bytearray creation from list and tuple - Python tracker
The Wayback Machine - https://web.archive.org/web/20220324083354/https://bugs.python.org/issue46993

➜

This issue tracker will soon become read-only and move to GitHub.
For a smoother transition, remember to log in and link your GitHub username to your profile.
For more information, see this post about the migration.

classification
Title: Speed up bytearray creation from list and tuple
Type: performance Stage: resolved
Components: Interpreter Core Versions: Python 3.11
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: asvetlov, gvanrossum, kumaraditya303
Priority: normal Keywords:

Created on 2022-03-12 09:40 by kumaraditya303, last changed 2022-03-15 14:49 by asvetlov. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 31834 merged kumaraditya303, 2022-03-12 09:40
Messages (2)
msg414987 - (view) Author: Kumar Aditya (kumaraditya303) * Date: 2022-03-12 09:40
The attached PR speeds up bytearray creation from list and tuple.

Benchmark (uses pyperf):
-----------------------------------------------------
import pyperf

runner = pyperf.Runner()
runner.timeit(name="bench bytearray",
              stmt="bytearray([42]*10000)",)
-----------------------------------------------------

Results:

-----------------------------------------------------
Mean +- std dev: [base] 74.8 us +- 5.5 us -> [patch] 53.2 us +- 3.3 us: 1.41x faster
-----------------------------------------------------
msg415244 - (view) Author: Andrew Svetlov (asvetlov) * (Python committer) Date: 2022-03-15 13:27
New changeset 6dfe09fc5fd5a3ddc6009d5656e635eae30c5240 by Kumar Aditya in branch 'main':
bpo-46993: Speed up bytearray creation from list and tuple (GH-31834)
https://github.com/python/cpython/commit/6dfe09fc5fd5a3ddc6009d5656e635eae30c5240
History
Date User Action Args
2022-03-15 14:49:22asvetlovsetstatus: open -> closed
resolution: fixed
stage: resolved
2022-03-15 13:27:34asvetlovsetnosy: + asvetlov
messages: + msg415244
2022-03-12 09:40:17kumaraditya303create