Re: Comments merging, pass 2
Bill Mill <[email protected]>
| Newsgroups | gmane.comp.web.pyblosxom.devel |
|---|---|
| Message-ID | <[email protected]> |
On Mon, 13 Dec 2004 09:27:22 -0500, Blake Winton <blake-dlUKtbW3TlBcVw/[email protected]> wrote: > Various people wrote: > > Logically, though, "return (a and [b] or [c])[0]" has to be one > > dictionary allocation larger than > > > > if a: return b > > else: return c > > Not if the list is lazily evaluated (as it indeed is in Python). > > Both cases evaluate a. If a is false, then a and [b] has to be false, > so [b] doesn't even get constructed, and it skips to the "or [c]". On > the other hand, if a is true, then "a and [b]" will be true, so [c] > doesn't get evaluated, since true or anything is still true. > I agree with you that a) Python is lazily evaluated and that b) one of either [b] or [c] is not constructed. However, one of those two needs to be constructed, and it isn't in the if/else example, right? So the memory allocation should be one *list* larger (I meant list when I said dictionary above) in the ternary-ish thing than in a normal if-else statement. Peace Bill Mill ------------------------------------------------------- SF email is sponsored by - The IT Product Guide Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now. http://productguide.itmanagersjournal.com/