[C++-sig] Re: Can't convert to unsigned int

David Abrahams dave at boost-consulting.com
Wed Dec 11 22:47:24 CET 2002

"Mike Rovner" <mike at bindkey.com> writes:

> "David Abrahams" <dave at boost-consulting.com> wrote in message
> news:uy96wwimc.fsf at boost-consulting.com...
>> Well, that's an interesting question.  A C++ unsigned long actually
>> has values that can't be represented as a Python INT.  Should
>> Boost.Python use Python LONGs to represent these?
> ...
>> This very issue has caused a lot of contention on Python-dev.  I'm
>> honestly unsure of what the best approach is, and would value a
>> discussion.
> 2.3+ is going to treat numbers outside int diapason as long.
What a beautiful word to apply for numeric ranges!

> So should BPL IMHO.

Believe it or not, those guys on python-dev know what's happening for
2.3+ ;-)

Int/Long unification (meaning, having a single type for both) is
slated to happen "sometime in the future", IIRC.

By 2.2.1, we already had:

    >>> 32768*65536

...so it's not clear to me what your statement meant. Certainly
PyInt_FromLong() is still going to take a signed long int parameter,
which will not represent numbers as great as the your constant on a
32-bit platform.

The real question is, how do we represent an unsigned integer
constant which requires exactly 32-bits?  We have 3 choices:

    1. We don't (current approach, probably not acceptable)

    2. PyInt_FromLong(x)

    3. A Python Long representing the actual value. It's not so easy
    to write down the correct expression for this one ;-)


                       David Abrahams
   dave at boost-consulting.com * http://www.boost-consulting.com
Boost support, enhancements, training, and commercial distribution

More information about the Cplusplus-sig mailing list