-
-
Notifications
You must be signed in to change notification settings - Fork 31.2k
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
Convert str(), bytes() and bytearray() to Argument Clinic #85506
Labels
3.10
only security fixes
performance
Performance or resource usage
topic-argument-clinic
topic-installation
topic-unicode
Comments
Constructors str(), bytes() and bytearray() were not converted to Argument Clinic because it was not possible to generate correct signature for them. But now there is other reason of using Argument Clinic -- it generates more efficient code for parsing arguments. The proposed PR converts str(), bytes() and bytearray() to Argument Clinic but generated docstrings are not used. $ ./python -m pyperf timeit -q --compare-to=../cpython-release2/python "str()"
Mean +- std dev: [/home/serhiy/py/cpython-release2/python] 81.9 ns +- 4.5 ns -> [/home/serhiy/py/cpython-release/python] 60.0 ns +- 1.9 ns: 1.36x faster (-27%)
$ ./python -m pyperf timeit -q --compare-to=../cpython-release2/python "str('abcdefgh')"
Mean +- std dev: [/home/serhiy/py/cpython-release2/python] 121 ns +- 3 ns -> [/home/serhiy/py/cpython-release/python] 87.6 ns +- 2.8 ns: 1.38x faster (-28%)
$ ./python -m pyperf timeit -q --compare-to=../cpython-release2/python "str(12345)"
Mean +- std dev: [/home/serhiy/py/cpython-release2/python] 188 ns +- 8 ns -> [/home/serhiy/py/cpython-release/python] 149 ns +- 5 ns: 1.27x faster (-21%)
$ ./python -m pyperf timeit -q --compare-to=../cpython-release2/python "str(b'abcdefgh', 'ascii')"
Mean +- std dev: [/home/serhiy/py/cpython-release2/python] 210 ns +- 7 ns -> [/home/serhiy/py/cpython-release/python] 164 ns +- 6 ns: 1.28x faster (-22%)
$ ./python -m pyperf timeit -q --compare-to=../cpython-release2/python "str(b'abcdefgh', 'ascii', 'strict')"
Mean +- std dev: [/home/serhiy/py/cpython-release2/python] 222 ns +- 9 ns -> [/home/serhiy/py/cpython-release/python] 170 ns +- 6 ns: 1.30x faster (-23%)
$ ./python -m pyperf timeit -q --compare-to=../cpython-release2/python "str(b'abcdefgh', encoding='ascii', errors='strict')"
Mean +- std dev: [/home/serhiy/py/cpython-release2/python] 488 ns +- 20 ns -> [/home/serhiy/py/cpython-release/python] 306 ns +- 5 ns: 1.59x faster (-37%)
$ ./python -m pyperf timeit -q --compare-to=../cpython-release2/python "bytes()"
Mean +- std dev: [/home/serhiy/py/cpython-release2/python] 85.1 ns +- 2.2 ns -> [/home/serhiy/py/cpython-release/python] 60.2 ns +- 2.3 ns: 1.41x faster (-29%)
$ ./python -m pyperf timeit -q --compare-to=../cpython-release2/python "bytes(8)"
Mean +- std dev: [/home/serhiy/py/cpython-release2/python] 160 ns +- 5 ns -> [/home/serhiy/py/cpython-release/python] 115 ns +- 4 ns: 1.39x faster (-28%)
$ ./python -m pyperf timeit -q --compare-to=../cpython-release2/python "bytes(b'abcdefgh')"
Mean +- std dev: [/home/serhiy/py/cpython-release2/python] 131 ns +- 6 ns -> [/home/serhiy/py/cpython-release/python] 91.0 ns +- 2.8 ns: 1.43x faster (-30%)
$ ./python -m pyperf timeit -q --compare-to=../cpython-release2/python "bytes('abcdefgh', 'ascii')"
Mean +- std dev: [/home/serhiy/py/cpython-release2/python] 190 ns +- 6 ns -> [/home/serhiy/py/cpython-release/python] 144 ns +- 5 ns: 1.32x faster (-24%)
$ ./python -m pyperf timeit -q --compare-to=../cpython-release2/python "bytes('abcdefgh', 'ascii', 'strict')"
Mean +- std dev: [/home/serhiy/py/cpython-release2/python] 214 ns +- 5 ns -> [/home/serhiy/py/cpython-release/python] 156 ns +- 4 ns: 1.37x faster (-27%)
$ ./python -m pyperf timeit -q --compare-to=../cpython-release2/python "bytes('abcdefgh', encoding='ascii', errors='strict')"
Mean +- std dev: [/home/serhiy/py/cpython-release2/python] 442 ns +- 9 ns -> [/home/serhiy/py/cpython-release/python] 269 ns +- 8 ns: 1.64x faster (-39%)
$ ./python -m pyperf timeit -q --compare-to=../cpython-release2/python "bytearray()"
Mean +- std dev: [/home/serhiy/py/cpython-release2/python] 93.5 ns +- 2.1 ns -> [/home/serhiy/py/cpython-release/python] 73.1 ns +- 1.8 ns: 1.28x faster (-22%)
$ ./python -m pyperf timeit -q --compare-to=../cpython-release2/python "bytearray(8)"
Mean +- std dev: [/home/serhiy/py/cpython-release2/python] 154 ns +- 3 ns -> [/home/serhiy/py/cpython-release/python] 117 ns +- 3 ns: 1.32x faster (-24%)
$ ./python -m pyperf timeit -q --compare-to=../cpython-release2/python "bytearray(b'abcdefgh')"
Mean +- std dev: [/home/serhiy/py/cpython-release2/python] 164 ns +- 5 ns -> [/home/serhiy/py/cpython-release/python] 131 ns +- 2 ns: 1.25x faster (-20%)
$ ./python -m pyperf timeit -q --compare-to=../cpython-release2/python "bytearray('abcdefgh', 'ascii')"
Mean +- std dev: [/home/serhiy/py/cpython-release2/python] 239 ns +- 7 ns -> [/home/serhiy/py/cpython-release/python] 193 ns +- 4 ns: 1.24x faster (-19%)
$ ./python -m pyperf timeit -q --compare-to=../cpython-release2/python "bytearray('abcdefgh', 'ascii', 'strict')"
Mean +- std dev: [/home/serhiy/py/cpython-release2/python] 260 ns +- 5 ns -> [/home/serhiy/py/cpython-release/python] 207 ns +- 10 ns: 1.26x faster (-21%)
$ ./python -m pyperf timeit -q --compare-to=../cpython-release2/python "bytearray('abcdefgh', encoding='ascii', errors='strict')"
Mean +- std dev: [/home/serhiy/py/cpython-release2/python] 505 ns +- 11 ns -> [/home/serhiy/py/cpython-release/python] 322 ns +- 7 ns: 1.57x faster (-36%) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
3.10
only security fixes
performance
Performance or resource usage
topic-argument-clinic
topic-installation
topic-unicode
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: