At 07:07 PM 11/26/2006 +0200, tomer filiba wrote:
sys.maxint makes more sense there.
no, it requires *infinity* to accomplish x - y == x; y != 0, for example:
while limit > 0: limit -= len(chunk)
Um, you do realize that you're not going to be able to fit sys.maxint strings into a list, right? That's over 2 billion *pointers* worth of memory, so at least 8 gigabytes on a 32-bit machine... that probably can't address more than 4 gigabytes of memory to start with. The code will fail with MemoryError long before you exhaust sys.maxint, even in the case where you're using only 1-character strings.
Um, you do realize that you're not going to be able to fit sys.maxint strings into a list, right?
i can multiply by four, thank you. of course i don't expect anyone to read a string *that* long.
besides, this *particular example* isn't important, it was just meant to show why someone might want to use it. why are people being so picky about the details of an example code?
first of all, a "while True" loop is not limited by sys.maxint, so i see no reason why i couldn't get the same result by subtracting from infinity. that may seem blunt, but it's a good way have the same code handle both cases (limited and unlimited reading).
all i was asking for was a better way to express and handle infinity (and nan), instead of the poor-man's version of "nan = 2e2222/3e3333". float.posinf or float.isinf(5.0) seem the right way to me.
for some reference, it seemed the right way to other people too: http://msdn2.microsoft.com/en-gb/library/system.double_methods.aspx http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Float.html
the third-party fp module is nice, but it ought to be part of the float type, or at least part of stdlib.
- - - - - -
if it were up to me, *literals* producing infinity would be a syntax error (of course i would allow computations to result in infinity).
for the reason why, consider this:
1e11111 == 2e22222
Phillip J. Eby