[issue4294] Macros for PyLong: sign, number of digits, fits in an int

Mark Dickinson report at bugs.python.org
Sat Mar 28 17:36:23 CET 2009


Mark Dickinson <dickinsm at gmail.com> added the comment:

[Mark]
> PyLong_NDIGITS should stay in longintrepr.h, though,
> since it's dependent on the representation.

[Victor]
>I don't understand why. [...]

I expressed myself badly.  I guess my point was that PyLong_SIGN
and PyLong_EQUALS_ZERO (and PyLong_IS_NEGATIVE) have an obvious
meaning for integers themselves, regardless of the particular
implementation chosen.  But there could be representations of
integers for which PyLong_NDIGITS doesn't even make sense, or
is ambiguous.  Furthermore, if the implementation of long integers
changes then the meanings of PyLong_SIGN and PyLong_EQUALS_ZERO won't
change, but the meaning of PyLong_NDIGITS might well do.

So it seems to me that PyLong_NDIGITS is only really a useful
macro for *this particular* implementation of integers---it's
something that should be internal to Objects/longobject.c and
Include/longintrepr.h, and not exposed to the rest of Python.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue4294>
_______________________________________


More information about the Python-bugs-list mailing list