-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New unique()
method on list
#13195
New unique()
method on list
#13195
Conversation
This (very) slightly reduce the list of test cases, and make it easier to find array related tests cases.
List now have a `unique()` method that return a copy of the list without duplicated elements. If other lists are provided as arguments to the method, it returns the union of all lists, without duplicated elements. ``` [1, 1, 2, 2, 3, 3].unique() == [1, 2, 3] [].unique([1, 2], [2, 3], [3, 4]) == [1, 2, 3, 4] ```
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the use case of the new method?
/cc @jpakkane
In a big project, I need to compute some dependencies between parts of the project. For instance, if I have
It would result in duplicated deps for libC. This is a first step towards what is described in #13189. |
I feel like it might be better to have a |
This could be another option. I guess it depends whether element order is important or not. |
At least in your example, it doesn't seem like order matters. I can't really think of a good example where an ordered unique list would be useful. |
Could you explain why you are computing this by hand as opposed to using Meson's builtin library deduplication? Working "in strings" is famously unreliable which is why we strongly recommend people to use things like |
As I already tried to explain in the linked discussion, there are two different cases where I need to follow the library dependencies, but in a context different from link dependencies: for translations, I need to extract strings from all dependent libraries; for tests I need to be able to compile and run unit tests from all dependent libraries. One way of doing that would be to have the dependency tree expressed as a datastructure, and to construct build, translation, and test dependencies from that. But I'm open to any other solution that could solve my problem. |
Translations, at least, should usually be done per domain, not per library-plus-dependencies. e.g. gettext() wants a compiled .mo named DOMAIN.mo, and calls to gettextdomain of DOMAIN mean to load translations from there. A single project will generally share translation catalogues between multiple executables/libraries so there is only one domain, though they might choose to have multiple domains for parts of the codebase with a lot of logical and code separation. So the usual translation process I'm aware of is "scan all source files into one big translation template". |
Our current process is that we extract a .pot file for each library, then we merge all the generated .pot files into a single .pot, and a single .mo file is generated from this. The problem is that is we have productB.exe and productC.exe that both depend on libA.dll, productB doesn't need translated strings from productC, and vice-versa, but they both need translated strings from libA. What I'd like to do is to generate, for each executable, a .pot file with only the strings needed for that executable. But if I add a new dependency for that executable, I want to get the strings from that dependency too. Am I missing something? |
This is the part I'm unfamiliar with. |
Closing, as I implemented what I needed in #13900. |
List now have a
unique()
method that return a copy of the list withoutduplicated elements.
If other lists are provided as arguments to the method, it returns the union
of all lists, without duplicated elements.