[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: gnulib-tool.py: Fix 'consider-using-with' pylint warnings.
From: |
Bruno Haible |
Subject: |
Re: gnulib-tool.py: Fix 'consider-using-with' pylint warnings. |
Date: |
Fri, 05 Apr 2024 14:58:40 +0200 |
Hi Collin,
> I've just changed these to 'sp.run()' since that function deals with
> everything for us and is recommended.
Yes, sp.run() and sp.call() are the variants that are most easy to use.
> The second is 'consider-using-set-comprehension'. Instead of calling
> set() on a list comprehension we can just use a set comprehension.
> I've additionally simplified this case:
>
> - version = sorted(set([ float(version)
> - for version in versions ]))[-1]
> + version = max({ float(version)
> + for version in versions })
>
> The previous method is just a less clear way of finding the max:
>
> print([1, 2, 3, 4][-1])
> 4
Sure. It was a translation of the shell code:
autoconf_minversion=`
for version in $prereqs; do echo $version; done |
LC_ALL=C sort -nru | sed -e 1q
`
Finding the maximum of a list directly is O(N). Finding it by sorting
the list is O(N log N). Therefore it is clear which of the two should
be preferred :)
Thanks, applied both patches.
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 <=
- 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, 2024/04/07
- 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