bug-gnulib
[Top][All Lists]
Advanced

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

Re: gnulib-tool.sh: Match sorting of gnulib-tool.py in output.


From: Collin Funk
Subject: Re: gnulib-tool.sh: Match sorting of gnulib-tool.py in output.
Date: Sat, 27 Apr 2024 15:40:17 -0700
User-agent: Mozilla Thunderbird

On 4/27/24 3:22 PM, Bruno Haible wrote:
> Thanks. There's a nit, though: These lines do not remove duplicates.
> 
>         module_set = set(modules)
>         modules = [ module
>                     for module in modules
>                     if module in module_set ]

Oops... Today isn't my day I guess.

I think the least annoying way to remove duplicates while preserving
order is this trick I mentioned a few months ago:

     print(list(dict.fromkeys([5, 1, 3, 100, 3, 3, 5, 5, 5])))
     [5, 1, 3, 100]

This works since we require Python 3.7 [1]:

    Changed in version 3.7: Dictionary order is guaranteed to be insertion
    order. This behavior was an implementation detail of CPython from 3.6.

There is also collections.OrderedDict for previous versions though.

> I confirm, it passes for me as well now.
> 
> But I'm confused: I thought part of the problem was that a libtests was being
> generated. Putting the modules in a different order makes the libtests
> disappear?? What is going on?

Likewise. The sorting of gnulib-tool.py was still incorrect, so that
commit was needed minus my silly set mistake.

Sounds like it is time for me to learn how the Python debuggers work
and step through it. :)

[1] https://docs.python.org/3/library/stdtypes.html#mapping-types-dict

Collin



reply via email to

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