tl;dr: I'd like to deprecate and eventually remove the option to use 15-bit 
digits in the PyLong implementation. Before doing so, I'd like to find out 
whether there's anyone still using 15-bit PyLong digits, and if so, why they're 
doing so.

History: the use of 30-bit digits in PyLong was introduced for Python 3.1 and 
Python 2.7, to improve performance of int (Python 3) / long (Python 2) 
arithmetic. At that time, we retained the option to use 15-bit digits, for two 
reasons:

- (1) use of 30-bit digits required C99 features (uint64_t and friends) at a 
time when we hadn't yet committed to requiring C99
- (2) it wasn't clear whether 30-bit digits would be a performance win on 
32-bit operating systems

Twelve years later, reason (1) no longer applies, and I suspect that:

- No-one is deliberately using the 15-bit digit option.
- There are few machines where using 15-bit digits is faster than using 30-bit 
digits.

But I don't have solid data on either of these suspicions, hence this post.

Removing the 15-bit digit option would simplify the code (there's significant 
mental effort required to ensure we don't break things for 15-bit builds when 
modifying Objects/longobject.c, and 15-bit builds don't appear to be exercised 
by the buildbots), remove a hidden compatibility trap (see b.p.o. issue 35037), 
widen the applicability of the various fast paths for arithmetic operations, 
and allow for some minor fast-path small-integer optimisations based on the 
fact that we'd be able to assume that presence of *two* extra bits in the C 
integer type rather than just one. As an example of the latter: if `a` and `b` 
are PyLongs that fit in a single digit, then with 15-bit digits and a 16-bit 
`digit` and `sdigit` type, `a + b` can't currently safely (i.e., without 
undefined behaviour from overflow) be computed with the C type `sdigit`. With 
30-bit digits and a 32-bit `digit` and `sdigit` type, `a + b` is safe.

Mark


*References*

Related b.p.o. issue: https://bugs.python.org/issue45569
MinGW compatibility issue: https://bugs.python.org/issue35037
Introduction of 30-bit digits: https://bugs.python.org/issue4258
_______________________________________________
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/python-dev@python.org/message/ZICIMX5VFCX4IOFH5NUPVHCUJCQ4Q7QM/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to