[issue44946] Integer operations are inefficient for "medium" integers.
Change by Xinhang Xu : -- nosy: +xuxinhang nosy_count: 3.0 -> 4.0 pull_requests: +28270 pull_request: https://github.com/python/cpython/pull/30044 ___ Python tracker <https://bugs.python.org/issue44946> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue46055] Speed up binary shifting operators
New submission from Xinhang Xu : See its PR. - Inspired by [bpo-44946](https://bugs.python.org/issue44946), I found there were no special shortcuts for shifting operation applied to "medium value" long object. So I modified CPython's VM to accelerate my python project where there is plenty of binary shifting operation. I guess somebody else might also need it. -- components: Interpreter Core messages: 408362 nosy: xuxinhang priority: normal pull_requests: 28289 severity: normal status: open title: Speed up binary shifting operators type: performance versions: Python 3.11 ___ Python tracker <https://bugs.python.org/issue46055> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue46055] Speed up binary shifting operators
Xinhang Xu added the comment: I post a comment to the PR showing its performance improvement. I paste it below. I think the result not bad. - I use timeit to measure time costs and any other operators or calls are excluded. For each testcase, the former is dcd2796 and the latter is this PR's base 036bbb1. 64-bit Release building. Run in Windows 10 1709 (64-bit) python -m timeit " i = 1; i <<= 3; i >>= 3" # small value (cost down by 36%) 500 loops, best of 5: 92.7 nsec per loop 200 loops, best of 5: 145 nsec per loop python -m timeit " i = 1; i <<= 10; i >>= 10" # medium value (-25%) 200 loops, best of 5: 114 nsec per loop 200 loops, best of 5: 151 nsec per loop python -m timeit " i = 1; i <<= 100; i >>= 100" # big value (-12%) 100 loops, best of 5: 209 nsec per loop 100 loops, best of 5: 238 nsec per loop -- ___ Python tracker <https://bugs.python.org/issue46055> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue45880] Performance regression of Int object operators. (Python 3.11)
New submission from Xinhang Xu : Hello. I'm working on a compute-bound project recently, so I tested several Python versions on my PC (Windows 10 64-bit), about Python's performance on operating Int object. All Python binaries are official distributions. Testcase #1 (simple xor op) Source: import cProfile as profile profile.run('for _ in range(5): 5 ^ 6') The given result: C:\Users\surface\Desktop\PythonTest>python-3.9.9-embed-amd64\python C:\Users\surface\python_test.py 3 function calls in 24.398 seconds Ordered by: standard name ncalls tottime percall cumtime percall filename:lineno(function) 1 24.398 24.398 24.398 24.398 :1() 10.0000.000 24.398 24.398 {built-in method builtins.exec} 10.0000.0000.0000.000 {method 'disable' of '_lsprof.Profiler' objects} C:\Users\surface\Desktop\PythonTest>python-3.10.0-embed-amd64\python C:\Users\surface\python_test.py 3 function calls in 27.941 seconds Ordered by: standard name ncalls tottime percall cumtime percall filename:lineno(function) 1 27.941 27.941 27.941 27.941 :1() 10.0000.000 27.941 27.941 {built-in method builtins.exec} 10.0000.0000.0000.000 {method 'disable' of '_lsprof.Profiler' objects} C:\Users\surface\Desktop\PythonTest>python-3.11.0a2-embed-amd64\python C:\Users\surface\python_test.py 3 function calls in 42.209 seconds Ordered by: standard name ncalls tottime percall cumtime percall filename:lineno(function) 1 42.209 42.209 42.209 42.209 :1() 10.0000.000 42.209 42.209 {built-in method builtins.exec} 10.0000.0000.0000.000 {method 'disable' of '_lsprof.Profiler' objects} Testcase #2 (simple add op) Source: import cProfile as profile profile.run('for _ in range(5): 5 + 6') The given result: C:\Users\surface\Desktop\PythonTest>python-3.9.9-embed-amd64\python C:\Users\surface\python_test.py 3 function calls in 24.599 seconds Ordered by: standard name ncalls tottime percall cumtime percall filename:lineno(function) 1 24.599 24.599 24.599 24.599 :1() 10.0000.000 24.599 24.599 {built-in method builtins.exec} 10.0000.0000.0000.000 {method 'disable' of '_lsprof.Profiler' objects} C:\Users\surface\Desktop\PythonTest>python-3.10.0-embed-amd64\python C:\Users\surface\python_test.py 3 function calls in 27.414 seconds Ordered by: standard name ncalls tottime percall cumtime percall filename:lineno(function) 1 27.414 27.414 27.414 27.414 :1() 10.0000.000 27.414 27.414 {built-in method builtins.exec} 10.0000.0000.0000.000 {method 'disable' of '_lsprof.Profiler' objects} C:\Users\surface\Desktop\PythonTest>python-3.11.0a2-embed-amd64\python C:\Users\surface\python_test.py 3 function calls in 43.675 seconds Ordered by: standard name ncalls tottime percall cumtime percall filename:lineno(function) 1 43.675 43.675 43.675 43.675 :1() 10.0000.000 43.675 43.675 {built-in method builtins.exec} 10.0000.0000.0000.000 {method 'disable' of '_lsprof.Profiler' objects} As you can see, Python 3.11 costs *much more* time to execute Int object operator. I have also tested the same cases on another Windows PC, the result shows the same. Is it a common thing? What's the reason for this problem? Thanks. -- messages: 406849 nosy: xuxinhang priority: normal severity: normal status: open title: Performance regression of Int object operators. (Python 3.11) type: performance versions: Python 3.11 ___ Python tracker <https://bugs.python.org/issue45880> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com