On Tue, Aug 11, 2009 at 08:06:39PM -0700, Brock Pytlik wrote: > client.py: > 1567: any reason not to move this import to the top?
Nope. > 1568: so... there's probably no real reason to do this optimization, > but I thought I'd throw it out there since it occurred to me... > > return reduce(lambda (attrval, match), y: y or fnmatch.fnmatch(attrval, > match), ( > (attrval, match) > for attr in iset > for match in attr_match[attr] > for attrval in action.attrlist(attr) > ), False) > > Would save calls to fnmatch once a match has been found. With this > structure, Good catch, but > I don't think there's a way to avoid the list walking once > a match has been found. Personally, I think I'd find a structure of > 'for x... for y... for z... if fnmatch(y,z): return True' clearer, > but I don't object to this if you like it this way. I went ahead and did it this way; I think it's more obvious. I'd originally implemented it as nested for-loops, but it was pretty grody. Forcing it into a comprehension made it cleaner, and now it comes back out into nested for-loops more cleanly, too. Webrev updated. Thanks, Danek _______________________________________________ pkg-discuss mailing list [email protected] http://mail.opensolaris.org/mailman/listinfo/pkg-discuss
