[Yum-devel] RHEL6.2 Assigned bugs

James Antill james at fedoraproject.org
Fri Sep 23 18:22:34 UTC 2011

On Fri, 2011-09-23 at 17:04 +0200, Nils Philippsen wrote:
> On Tue, 2011-09-20 at 11:29 -0400, James Antill wrote:
> >  There's no need to make this a multiline list generator, just using a
> > for loop and append() is basically identical speed wise ... and stupid
> > people like me can more easily read it :).
> You'll notice that we really want to annoy people when we start using
> map() and filter(). :-P

 My current feelings, which have changed over the last few years, is
that given:


 foo = []
 for x in blah:
      if y:

 foo = [x for x in blah if y]

 foo = filter(lambda x: y, blah)

...#1 is pretty much identical speed wise to the others, and everybody
can understand it easily. The only downside is that for the most simple
cases it has 2-4 times the vertically whitespace (but not much more
typing). So if there is _any_ doubt, just use #1.

 #2 is fine when all of "x" "blah" and "y" are fairly simple. The limit
is probably something like:

        return [pkg.pkgtup for pkg in self.returnPackages(patterns=patterns,

...if it's just the test that is "non-simple" you can always put it in a function and use:

 foo = [x for x in blah if y(...)]

...if it's just the "blah", you can always use a generator. Or, again, just use a for loop.

 #3 is fine when the first arg. is _naturally_ a function, and the
second is naturally a variable ... but just using a #2 is not a bad idea
anyway. We do not worship lisp :).

 The general idea being that there is no reason to be "clever" for no
reason, esp. as we have to do that too often anyway.

More information about the Yum-devel mailing list