aleaxit / gmpy

General Multi-Precision arithmetic for Python 2.6+/3+ (GMP, MPIR, MPFR, MPC)
https://gmpy2.readthedocs.io/en/latest/
GNU Lesser General Public License v3.0
510 stars 86 forks source link

bit_count() not found #416

Closed Nogi-v-Ruki closed 1 year ago

Nogi-v-Ruki commented 1 year ago

Hi! @Python 3.10 gmpy2 2.1.2 (latest available with pip install) @Win10 x64 there is no method/function .bit_count(): neither as gmpy2.bit_count(number) => "AttributeError: module 'gmpy2' has no attribute 'bit_count'" nor as number.bit_count() => "AttributeError: 'mpz' object has no attribute 'bit_count'" Thank you!

Nogi-v-Ruki commented 1 year ago

Oopse! It seems that gmpy2.popcount(number) does the wanted action. Probably, just ReadTheDocs needs some update.

casevh commented 1 year ago

FYI, gmpy2 2.1.5 is available via pip.

C:\Users\User>py -3.10 -m pip install gmpy2
Collecting gmpy2
  Downloading gmpy2-2.1.5-cp310-cp310-win_amd64.whl (1.1 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.1/1.1 MB 7.0 MB/s eta 0:00:00
Installing collected packages: gmpy2
Successfully installed gmpy2-2.1.5

bit_count and popcount are both available in 2.1.5.

>>> import gmpy2
>>> gmpy2.version()
'2.1.5'
>>> gmpy2.mpz(1234).bit_count()
5
>>> gmpy2.bit_count(1234)
5
>>> gmpy2.popcount(1234)
5

Can you try upgrading via pip install --upgrade gmpy2?

Nogi-v-Ruki commented 1 year ago

Hi! «pip install --upgrade gmpy2» worked fine! both n.bit_count() and gmpy2.bit_count(n) are available. Thanks for your invaluable efforts!   Best regards! Albert Kiselev aka @.***

Воскресенье, 25 июня 2023, 22:52 +07:00 от casevh @.***>:     FYI, gmpy2 2.1.5 is available via pip. C:\Users\User>py -3.10 -m pip install gmpy2 Collecting gmpy2 Downloading gmpy2-2.1.5-cp310-cp310-win_amd64.whl (1.1 MB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.1/1.1 MB 7.0 MB/s eta 0:00:00 Installing collected packages: gmpy2 Successfully installed gmpy2-2.1.5

bit_count and popcount are both available in 2.1.5.

import gmpy2 gmpy2.version() '2.1.5' gmpy2.mpz(1234).bit_count() 5 gmpy2.bit_count(1234) 5 gmpy2.popcount(1234) 5

Can you try upgrading via pip install --upgrade gmpy2? — Reply to this email directly, view it on GitHub , or unsubscribe . You are receiving this because you modified the open/close state. Message ID: <aleaxit/gmpy/issues/416/1606140709 @ github . com>