Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.fsmpi.rwth-aachen.de!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: Marko Rauhamaa Newsgroups: comp.lang.python Subject: Re: (test) ? a:b Date: Fri, 24 Oct 2014 21:46:33 +0300 Organization: A noiseless patient Spider Lines: 16 Message-ID: <87k33pb912.fsf@elektro.pacujo.net> References: <54476af8$0$21651$426a74cc@news.free.fr> <7839376e-fc27-4299-ae63-4ddf17ef9a8a@googlegroups.com> <7d2ea3c1-504e-4f5c-8338-501b1483df38@googlegroups.com> <878uk6x5nd.fsf@elektro.pacujo.net> <544a1016$0$13000$c3e8da3$5496439d@news.astraweb.com> <87tx2tvmea.fsf@elektro.pacujo.net> <544a4ef7$0$12984$c3e8da3$5496439d@news.astraweb.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: mx02.eternal-september.org; posting-host="ff5cf27ef3d5b31f034d3b72bdc27a41"; logging-data="16240"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18hc8GlRso6UPsSdkiVSgkJ" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) Cancel-Lock: sha1:4eHGvxRj6QffLgv+hSqzuf8xHso= sha1:jwY6aUqZDIBq9o17i/zcMo+zV28= Xref: csiph.com comp.lang.python:79604 Ian Kelly : >> j = (lambda: 3, lambda: j + 1)[j < 10]() > Yes, the lambda approach falls victim to function calls being slow. That's just a deficiency in the compiler. There's nothing there that prevents the optimizer from translating the expression into the equivalent if statement. At any rate, the only issue at hand is the obviousness of the idiom. You should generally choose the syntax that best expresses the logic of the program. Marko