[Python-Dev] Deprecation warning on integer shifts and such
Jack Jansen
Jack.Jansen@oratrix.com
Mon, 12 Aug 2002 23:24:40 +0200
On maandag, augustus 12, 2002, at 10:49 , Guido van Rossum wrote:
>> Can we please make this change in a backwards-compatible way,
>> i.e. leave the i and l formats alone and use something new for
>> "range-checked-int" and "range-checked-long"?
>
> Um, they *already* do range checking. 'i' requires that the value
> (whether it comes from a Python int or a Python long) is in the range
> [INT_MIN, INT_MAX]. 'l' doesn't do range checking on Python ints
> (because they are defined to fit in a C long), but for a Python long
> it requires that the value fits in the range of a signed C long,
> i.e. [-sys.maxint-1, sys.maxint].
Yes, but due to the way the parser works everything works fine
for me. In
the constant definition file it says "foo = 0xff000000". The
parser turns this
into a negative integer. Fine with me, the bits are the same,
and PyArg_Parse
doesn't complain.
> If we really believe that there's more code (in the world, not just in
> the core CVS tree) that uses 'i' or 'l' for masks than that uses it
> for signed values, we cold fix 'i' and 'l' this way, and add new codes
> for code that really wants signed values. Still, all that code would
> have to be fixed somehow and we would have to track it down.
I think what it boils down to is what Python's model of the
world is: C or mathematics. It used to be C, which is probably
the one reason Python caught on initially (whereas ABC with it's
mathematical model didn't, really). I can see the reason behind
moving towards a more consistent world view, where integers are
integers, be they 32 bits or more, where strings are strings, be
they unicode or ascii, and I even agree with it, up to a point.
The drawback is that it will make it more difficult to interface
Python to the real world, where integers have a size, characters
are 8 bits, binary data is "char *" too, unicode has funny APIs,
etc. And I happen to feel responsible for a lot of this real
world interfacing code:-)
> Before you start to panic, can you please try to import all those
> modules
I just did so, see my other mail. You're right, the problem is
theoretically big, but pretty manageable in practice.
--
- Jack Jansen <Jack.Jansen@oratrix.com>
http://www.cwi.nl/~jack -
- If I can't dance I don't want to be part of your revolution --
Emma Goldman -