[New-bugs-announce] [issue37837] add internal _PyLong_FromUnsignedChar() function

Sergey Fedoseev report at bugs.python.org
Tue Aug 13 06:29:55 EDT 2019


New submission from Sergey Fedoseev <fedoseev.sergey at gmail.com>:

When compiled with default NSMALLPOSINTS, _PyLong_FromUnsignedChar() is significantly faster than other PyLong_From*():

$ python -m perf timeit -s "from collections import deque; consume = deque(maxlen=0).extend; b = bytes(2**20)" "consume(b)" --compare-to=../cpython-master/venv/bin/python
/home/sergey/tmp/cpython-master/venv/bin/python: ..................... 7.10 ms +- 0.02 ms
/home/sergey/tmp/cpython-dev/venv/bin/python: ..................... 4.29 ms +- 0.03 ms

Mean +- std dev: [/home/sergey/tmp/cpython-master/venv/bin/python] 7.10 ms +- 0.02 ms -> [/home/sergey/tmp/cpython-dev/venv/bin/python] 4.29 ms +- 0.03 ms: 1.66x faster (-40%)

It's mostly useful for bytes/bytearray, but also can be used in several other places.

----------
components: Interpreter Core
messages: 349540
nosy: sir-sigurd
priority: normal
severity: normal
status: open
title: add internal _PyLong_FromUnsignedChar() function
type: performance
versions: Python 3.9

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue37837>
_______________________________________


More information about the New-bugs-announce mailing list