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.
Created on 2016年08月07日 19:22 by methane, last changed 2022年04月11日 14:58 by admin. This issue is now closed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| fast-bytearray-fromobject.patch | methane, 2016年08月07日 19:22 | review | ||
| fast-bytearray-fromobject.patch | methane, 2016年08月09日 18:46 | review | ||
| Messages (8) | |||
|---|---|---|---|
| msg272130 - (view) | Author: Inada Naoki (methane) * (Python committer) | Date: 2016年08月07日 19:22 | |
When bytes(x), bytes_new checks if x is integer via PyNumber_AsSize_t(x). It cause TypeError internally. When x is not an integer, especially bytearray or memoryview, the internal exception cause significant overhead. # HEAD $ ./python -m timeit -s 'data=bytearray(b"xyz")' 'bytes(data)' 1000000 loops, best of 3: 0.696 usec per loop $ ./python -m timeit -s 'data=bytearray(b"xyz")' 'bytes(data)' 1000000 loops, best of 3: 0.699 usec per loop $ ./python -m timeit -s 'data=bytearray(b"xyz")' 'bytes(data)' 1000000 loops, best of 3: 0.701 usec per loop # this patch $ ./python -m timeit -s 'data=bytearray(b"xyz")' 'bytes(data)' 1000000 loops, best of 3: 0.265 usec per loop $ ./python -m timeit -s 'data=bytearray(b"xyz")' 'bytes(data)' 1000000 loops, best of 3: 0.265 usec per loop $ ./python -m timeit -s 'data=bytearray(b"xyz")' 'bytes(data)' 1000000 loops, best of 3: 0.267 usec per loop |
|||
| msg272131 - (view) | Author: Stéphane Wirtel (matrixise) * (Python committer) | Date: 2016年08月07日 20:02 | |
the patch seems to be fine. |
|||
| msg272249 - (view) | Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) | Date: 2016年08月09日 13:47 | |
bytearray suffers from the same issue. It would be nice to optimize it too. |
|||
| msg272258 - (view) | Author: Stéphane Wirtel (matrixise) * (Python committer) | Date: 2016年08月09日 16:11 | |
Hi Serhiy Thank you for your feedback. Stephane |
|||
| msg272260 - (view) | Author: Inada Naoki (methane) * (Python committer) | Date: 2016年08月09日 18:46 | |
Thanks for comments. |
|||
| msg272261 - (view) | Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) | Date: 2016年08月09日 19:18 | |
LGTM. |
|||
| msg272721 - (view) | Author: Roundup Robot (python-dev) (Python triager) | Date: 2016年08月15日 06:46 | |
New changeset 789a42401009 by Serhiy Storchaka in branch 'default': Issue #27704: Optimized creating bytes and bytearray from byte-like objects https://hg.python.org/cpython/rev/789a42401009 |
|||
| msg272739 - (view) | Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) | Date: 2016年08月15日 08:55 | |
Thank you for your contribution Naoki. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:58:34 | admin | set | github: 71891 |
| 2016年08月15日 08:55:51 | serhiy.storchaka | set | messages: + msg272739 |
| 2016年08月15日 08:55:08 | serhiy.storchaka | set | status: open -> closed resolution: fixed stage: commit review -> resolved |
| 2016年08月15日 06:46:35 | python-dev | set | nosy:
+ python-dev messages: + msg272721 |
| 2016年08月09日 19:18:45 | serhiy.storchaka | set | assignee: serhiy.storchaka messages: + msg272261 stage: commit review |
| 2016年08月09日 18:46:08 | methane | set | files:
+ fast-bytearray-fromobject.patch messages: + msg272260 |
| 2016年08月09日 16:11:13 | matrixise | set | messages: + msg272258 |
| 2016年08月09日 13:47:45 | serhiy.storchaka | set | nosy:
+ serhiy.storchaka messages: + msg272249 |
| 2016年08月07日 20:02:49 | matrixise | set | nosy:
+ vstinner, matrixise messages: + msg272131 |
| 2016年08月07日 19:22:27 | methane | create | |