[issue46407] optimizing `1 << n` or `2 ** n` and modulo-only operations

2022-01-31 Thread Łukasz Langa

Łukasz Langa  added the comment:


New changeset 768569325abc0a9cd5aae65c531889ec390847aa by Ken Jin in branch 
'main':
bpo-46407: Fix long_mod refleak (GH-31025)
https://github.com/python/cpython/commit/768569325abc0a9cd5aae65c531889ec390847aa


--
nosy: +lukasz.langa

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue46407] optimizing `1 << n` or `2 ** n` and modulo-only operations

2022-01-30 Thread Ken Jin


Change by Ken Jin :


--
nosy: +kj
nosy_count: 6.0 -> 7.0
pull_requests: +29206
pull_request: https://github.com/python/cpython/pull/31025

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue46407] optimizing `1 << n` or `2 ** n` and modulo-only operations

2022-01-27 Thread Tim Peters


Tim Peters  added the comment:

I only merged the split-off PR that added new remainder-only functions. Still 
thinking about the `1 << n` and `2**n` one.

--
assignee:  -> tim.peters
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue46407] optimizing `1 << n` or `2 ** n` and modulo-only operations

2022-01-27 Thread Tim Peters


Tim Peters  added the comment:


New changeset f10dafc430279b4e6cf5b981ae3d1d76e8f431ad by Crowthebird in branch 
'main':
bpo-46407: Optimizing some modulo operations (GH-30653)
https://github.com/python/cpython/commit/f10dafc430279b4e6cf5b981ae3d1d76e8f431ad


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue46407] optimizing `1 << n` or `2 ** n` and modulo-only operations

2022-01-17 Thread theeshallnotknowethme


Change by theeshallnotknowethme :


--
pull_requests: +28854
pull_request: https://github.com/python/cpython/pull/30653

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue46407] optimizing `1 << n` or `2 ** n` and modulo-only operations

2022-01-17 Thread theeshallnotknowethme


theeshallnotknowethme  added the comment:

Also how would it be implemented? in terms of a PyLongObject or just a uint64_t?

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue46407] optimizing `1 << n` or `2 ** n` and modulo-only operations

2022-01-17 Thread theeshallnotknowethme


theeshallnotknowethme  added the comment:

> Another option to consider would be a table lookup of a pre-computed table of 
> [1 << i for i in range(64)].
Does it have a significantly better performance compared to not having a table 
lookup?

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue46407] optimizing `1 << n` or `2 ** n` and modulo-only operations

2022-01-17 Thread Dennis Sweeney


Dennis Sweeney  added the comment:

Another option to consider would be a table lookup of a pre-computed table of 
[1 << i for i in range(64)].

--
nosy: +Dennis Sweeney

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue46407] optimizing `1 << n` or `2 ** n` and modulo-only operations

2022-01-17 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
nosy: +mark.dickinson, rhettinger, stutzbach, tim.peters

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue46407] optimizing `1 << n` or `2 ** n` and modulo-only operations

2022-01-16 Thread theeshallnotknowethme


Change by theeshallnotknowethme :


--
type:  -> performance

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue46407] optimizing `1 << n` or `2 ** n` and modulo-only operations

2022-01-16 Thread theeshallnotknowethme


Change by theeshallnotknowethme :


--
keywords: +patch
pull_requests: +28831
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/30628

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue46407] optimizing `1 << n` or `2 ** n` and modulo-only operations

2022-01-16 Thread theeshallnotknowethme


theeshallnotknowethme  added the comment:

Note that `n` should not be over PY_SSIZE_T_MAX, else an error should occur.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue46407] optimizing `1 << n` or `2 ** n` and modulo-only operations

2022-01-16 Thread theeshallnotknowethme


New submission from theeshallnotknowethme :

Optimize calculating powers of 2 for integers. Does not include optimizing 
modular exponentiation because benchmarking shows current version of modular 
exponentiation is faster. Also optimizes any call with the structure 
`l_divmod(a, b, NULL, )`.

> python_modified.exe -m timeit -s "x = 2" "x**1000"
1 loops, best of 5: 33.1 usec per loop
> python_current.exe -m timeit -s "x = 2" "x**1000"
10 loops, best of 5: 35.2 msec per loop

--
components: Interpreter Core
messages: 410744
nosy: February291948
priority: normal
severity: normal
status: open
title: optimizing `1 << n` or `2 ** n` and modulo-only operations
versions: Python 3.11

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com