Rationale for core Python numeric types

Michael Hudson mwh at python.net
Mon Jul 26 12:04:49 EDT 2004


Josef Dalcolmo <dalcolmo at vh-s.de> writes:

> on Thu, 15 Jul 2004 15:14:47 -0400
> Tim Peters <tim.peters at gmail.com> wrote:
> 
> 
> > Python longs are 2's-complement with a conceptually infinite number of
> > sign bits (whether 0 or 1).  So ~0 will be, like ~0L today, an
> > infinite string of 1 bits.  Even today:
> > 
> > >>> (~0) & 0xff
> > 255
> > >>> (~0L) & 0xff
> > 255L
> > >>> ~0 == ~0L == -1
> > True
> 
> 
> Ok, so using longs should be the way of the future in Python, but
> unfortunately trying to pass to fcntl.fcntl an argument of type long
> fails with a message saying it can take only int's. When I define an
> int where the MSB (of 32 bits) is set, I get a deprecation
> warning. I guess the module fcntl needs some updating.

Weird.  What version of Python?  Can you paste an example?  I can
successfully pass longs to fcntl and ioctl on my machine with Python
2.3.3...

Cheers,
mwh

-- 
  we're already scrubbing the face of intuition with steel wool,
  setting it on fire, then putting it out with an axe <wink>.
                      -- Tim Peters, on comparing recursive structures



More information about the Python-list mailing list