Re: int vs long

2007-12-20 Thread Nick Craig-Wood
Hendrik van Rooyen <[EMAIL PROTECTED]> wrote: > "Nick Craig-Wood" wrote: > > So you might see longs returned when you expected ints if the result > > was >= 0x800. > > did you mean 0x8000 ? > > ;-) Yes - well spotted! -- Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.c

Re: int vs long

2007-12-17 Thread Hendrik van Rooyen
"Nick Craig-Wood" wrote: > So you might see longs returned when you expected ints if the result > was >= 0x800. did you mean 0x8000 ? ;-) - Hendrik -- http://mail.python.org/mailman/listinfo/python-list

Re: int vs long

2007-12-17 Thread Gabriel Genellina
En Mon, 17 Dec 2007 10:30:05 -0300, Nick Craig-Wood <[EMAIL PROTECTED]> escribió: > Gabriel Genellina <[EMAIL PROTECTED]> wrote: >> En Sun, 16 Dec 2007 20:28:02 -0300, Troels Thomsen <"nej >> tak..."@bag.python.org> escribi?: >> >> > >> > The readFile function from the win32 package aparently

Re: int vs long

2007-12-17 Thread Nick Craig-Wood
Gabriel Genellina <[EMAIL PROTECTED]> wrote: > En Sun, 16 Dec 2007 20:28:02 -0300, Troels Thomsen <"nej > tak..."@bag.python.org> escribi?: > > > > > The readFile function from the win32 package aparently really expect an > > integer : > > > > def inWaiting(self): > > """Returns th

Re: int vs long

2007-12-16 Thread Gabriel Genellina
En Sun, 16 Dec 2007 20:28:02 -0300, Troels Thomsen <"nej tak..."@bag.python.org> escribi�: > > The readFile function from the win32 package aparently really expect an > integer : > > def inWaiting(self): > """Returns the number of bytes waiting to be read""" > flags, comstat

int vs long

2007-12-16 Thread Troels Thomsen
The readFile function from the win32 package aparently really expect an integer : def inWaiting(self): """Returns the number of bytes waiting to be read""" flags, comstat = ClearCommError(self.__handle) return comstat.cbInQue ReadFile(h, s.inWaiting()) My code crash

Re: int vs long

2007-06-04 Thread Peter Otten
Marc 'BlackJack' Rintsch wrote: > Seems to be the same Python version, just build three days earlier and > with a different GCC version.  Weird. Indeed. Also, it seems to prove the explanation wrong that I just in response to Douglas' post... Peter -- http://mail.python.org/mailman/listinfo/py

Re: int vs long

2007-06-04 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, Peter Otten wrote: >> Hm, my test above was from 2.5!? > > Then your installation is broken. What does > import itertools itertools > '/usr/local/lib/python2.5/lib-dynload/itertools.so'> > > print? Python 2.5 (r25:51908, Oct 6 2006, 15:22:41) [GCC 4.1.2 200

Re: int vs long

2007-06-04 Thread Peter Otten
Douglas Woodrow wrote: > On Mon, 4 Jun 2007 10:50:14, Peter Otten <[EMAIL PROTECTED]> wrote This is fixed in Python2.5: >>> Hm, my test above was from 2.5!? >> >>Then your installation is broken. What does >> > import itertools > itertools >>>'/usr/local/lib/python2.5/lib-dy

Re: int vs long

2007-06-04 Thread Douglas Woodrow
On Mon, 4 Jun 2007 10:50:14, Peter Otten <[EMAIL PROTECTED]> wrote >>> >>> This is fixed in Python2.5: >>> >> Hm, my test above was from 2.5!? > >Then your installation is broken. What does > import itertools itertools >'/usr/local/lib/python2.5/lib-dynload/itertools.so'> > >print? Mayb

Re: int vs long

2007-06-04 Thread Peter Otten
Marc 'BlackJack' Rintsch wrote: > In <[EMAIL PROTECTED]>, Peter Otten wrote: > >> Marc 'BlackJack' Rintsch wrote: >> >> from itertools import count >> from sys import maxint >> c = count(maxint) >> c.next() >>> 2147483647 >> c.next() >>> -2147483648 >>> >>> What I find most

Re: int vs long

2007-06-04 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, Peter Otten wrote: > Marc 'BlackJack' Rintsch wrote: > > from itertools import count > from sys import maxint > c = count(maxint) > c.next() >> 2147483647 > c.next() >> -2147483648 >> >> What I find most disturbing here, is that it happens silently. I

Re: int vs long

2007-06-04 Thread Peter Otten
Paul Rubin wrote: > Dan Bishop <[EMAIL PROTECTED]> writes: >> If you ever do, it's trivial to write your own enumerate(): >> def enumerate(seq): >> index = 0 >> for item in seq: >> yield (index, item) >> index += 1 > > That's a heck of a lot slower than the builtin, and if

Re: int vs long

2007-06-04 Thread Peter Otten
Marc 'BlackJack' Rintsch wrote: > In <[EMAIL PROTECTED]>, Alex Martelli wrote: > >> Paul Rubin wrote: >> >>> Dan Bishop <[EMAIL PROTECTED]> writes: >>> > If you ever do, it's trivial to write your own enumerate(): >>> > def enumerate(seq): >>> > index = 0 >>> >

Re: int vs long

2007-06-04 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, Alex Martelli wrote: > Paul Rubin wrote: > >> Dan Bishop <[EMAIL PROTECTED]> writes: >> > If you ever do, it's trivial to write your own enumerate(): >> > def enumerate(seq): >> > index = 0 >> > for item in seq: >> > yield (index,

Re: int vs long

2007-06-03 Thread Alex Martelli
Paul Rubin wrote: > Dan Bishop <[EMAIL PROTECTED]> writes: > > If you ever do, it's trivial to write your own enumerate(): > > def enumerate(seq): > > index = 0 > > for item in seq: > > yield (index, item) > > index += 1 > > That's a heck of a lo

Re: int vs long

2007-06-03 Thread Paul Rubin
Dan Bishop <[EMAIL PROTECTED]> writes: > If you ever do, it's trivial to write your own enumerate(): > def enumerate(seq): > index = 0 > for item in seq: > yield (index, item) > index += 1 That's a heck of a lot slower than the builtin, and if you're running it often enough

Re: int vs long

2007-06-03 Thread Dan Bishop
On Jun 2, 11:55 pm, kaens <[EMAIL PROTECTED]> wrote: > On 02 Jun 2007 20:18:02 -0700, Paul Rubin > > <"http://phr.cx"@nospam.invalid> wrote: > > Dan Bishop <[EMAIL PROTECTED]> writes: > > > Note that recent versions of Python automatically promote the results > > > of integer arithmetic to long if

Re: int vs long

2007-06-03 Thread jay
Hi Dan, Paul, and Kaens, Thanks very much for replying to my question. I appreciate you all taking the time to answer this for me! Jay > On 02 Jun 2007 20:18:02 -0700, Paul Rubin > <"http://phr.cx"@nospam.invalid> wrote: >> Dan Bishop <[EMAIL PROTECTED]> writes: >> > Note that recent versio

Re: int vs long

2007-06-02 Thread kaens
On 02 Jun 2007 20:18:02 -0700, Paul Rubin <"http://phr.cx"@nospam.invalid> wrote: > Dan Bishop <[EMAIL PROTECTED]> writes: > > Note that recent versions of Python automatically promote the results > > of integer arithmetic to long if necessary, so the distinction is less > > relevant than it used t

Re: int vs long

2007-06-02 Thread Paul Rubin
Dan Bishop <[EMAIL PROTECTED]> writes: > Note that recent versions of Python automatically promote the results > of integer arithmetic to long if necessary, so the distinction is less > relevant than it used to be. Note however that even in recent versions, there are still parts of Python that get

Re: int vs long

2007-06-02 Thread Dan Bishop
On Jun 2, 9:30 pm, jay <[EMAIL PROTECTED]> wrote: > I was reading in a book that the 'int' type can store whole numbers > up to 32 bits. I'm not exactly sure what that means, but got me > wondering, what's the largest number you can store as an 'int' before > you need to switch over to 'long'? sy

int vs long

2007-06-02 Thread jay
I was reading in a book that the 'int' type can store whole numbers up to 32 bits. I'm not exactly sure what that means, but got me wondering, what's the largest number you can store as an 'int' before you need to switch over to 'long'? Thanks for looking at my question. Jay -- http://mai