bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: gnulib-tool.py: lists vs. sets


From: Bruno Haible
Subject: Re: gnulib-tool.py: lists vs. sets
Date: Sun, 07 Apr 2024 13:56:29 +0200

Hi Collin,

> I was trying to cleanup list comprehensions from this:
> 
>     file_table = sorted([ file
>                           for file in table1
>                           if file not in table2 ])
> 
> to this:
> 
>     file_table = sorted(set(table1).difference(table2))
> 
> because I find them easier to follow.

In my opinion, both are good ways to express the same thing.
The second one is more expressive; but we all can store a 3-lines
snippet of code in our short-term memory.

The interesting question here is: is table2 a possibly long list?
If yes, then can we convert it to a set, without impairing the
clarity of the code?

Bruno






reply via email to

[Prev in Thread] Current Thread [Next in Thread]