how to avoid checking the same condition repeatedly ?

Neil Cerutti neilc at norwich.edu
Tue Oct 29 09:44:51 EDT 2013


On 2013年10月28日, Nobody <nobody at nowhere.com> wrote:
> On 2013年10月28日 09:50:19 +0000, Wolfgang Maier wrote:
>> So my question is: is there an agreed-upon generally best way
>> of dealing with this?
>> Yes. Just leave the test inside the loop.
>> If you're sufficiently concerned about performance that you're
> willing to trade clarity for it, you shouldn't be using Python
> in the first place.

When you detect a code small, as Wolfgang did, e.g., "I'm
repeating the same exact test condition in several places," you
should not simply ignore it, even in Python.
-- 
Neil Cerutti


More information about the Python-list mailing list

AltStyle によって変換されたページ (->オリジナル) /