On Tue, Oct 6, 2009 at 5:08 PM, Wayne <sri...@gmail.com> wrote: > On Tue, Oct 6, 2009 at 9:58 AM, Dave Angel <da...@ieee.org> wrote: >> >> <snip> >> >> No, because you're not assured that all integers that are equal are the >> same object. Python optimizes that for small integers, but there's no >> documented range that you can count on it. >> > > But for this specific case - checking a return code against zero, should it > still be considered unreliable? The only case that you are looking for > correctness is 0 == 0, any other case should evaluate as false, so I guess > the question is does python always optimize for zero? Any other optimization > is irrelevant, AFAIK.
Never rely on optimizations like this being done, or on them not being done. The only save way to code is having your code work in both cases. -- André Engels, andreeng...@gmail.com _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor