This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

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, kumaraditya
Priority: normal Keywords:

Created on 2022-03-12 09:40 by kumaraditya, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 31834 merged kumaraditya, 2022-03-12 09:40
Messages (2)
msg414987 - (view) Author: Kumar Aditya (kumaraditya) * (Python triager) 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-04-11 14:59:57adminsetgithub: 91149
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:17kumaradityacreate