[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
- gnulib-tool.py: Fix 'consider-using-with' pylint warnings., Collin Funk, 2024/04/05
- gnulib-tool.py: Use 'Any' instead of type unions in GLConfig., Collin Funk, 2024/04/05
- Re: gnulib-tool.py: Fix 'consider-using-with' pylint warnings., Bruno Haible, 2024/04/05
- Re: gnulib-tool.py: Fix 'consider-using-with' pylint warnings., Collin Funk, 2024/04/05
- Re: gnulib-tool.py: lists vs. sets, Bruno Haible, 2024/04/06
- Re: gnulib-tool.py: lists vs. sets, Collin Funk, 2024/04/06
- Re: gnulib-tool.py: lists vs. sets,
Bruno Haible <=
- Re: gnulib-tool.py: lists vs. sets, Collin Funk, 2024/04/07
- Re: Python list micro-benchmarks, Bruno Haible, 2024/04/07
- Re: Python list micro-benchmarks, Collin Funk, 2024/04/07
- Re: Python list micro-benchmarks, Paul Eggert, 2024/04/07
- Re: Python list micro-benchmarks, Collin Funk, 2024/04/07
- Re: Python list micro-benchmarks, Bruno Haible, 2024/04/08
- Re: Python list micro-benchmarks, Collin Funk, 2024/04/08
- Re: Python list micro-benchmarks, Bruno Haible, 2024/04/08
- Re: Python list micro-benchmarks, Paul Eggert, 2024/04/08
- Re: Python list micro-benchmarks, Collin Funk, 2024/04/08