Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@jaimergp
Copy link
Contributor

@jaimergp jaimergp commented Apr 22, 2025

Description

Noticed this unnecessary IndexedSet incursions when all we need is dict.fromkeys for deduplication. I initially saw this in #14776 and thought it would be more widespread, so that's why I started in this branch, but to my surprise that's everything.

We do have a lot of (indiscriminate?) IndexedSet usage but I won't touch the apparently legitimate cases here. Just the tuple(IndexedSet(...)) bits.

Checklist - did you ...

  • Add a file to the news directory (using the template) for the next release's release notes?
  • Add / update necessary tests?
  • Add / update outdated documentation?

@conda-bot conda-bot added the cla-signed [bot] added once the contributor has signed the CLA label Apr 22, 2025
@github-project-automation github-project-automation bot moved this to πŸ†• New in πŸ”Ž Review Apr 22, 2025
@codspeed-hq
Copy link

codspeed-hq bot commented Apr 22, 2025

CodSpeed Performance Report

Merging #14777 will not alter performance

Comparing jaimergp:indexedset-dictfromkeys (cc53cde) with main (c3f1b39)

Summary

βœ… 21 untouched benchmarks

@jaimergp jaimergp moved this to In Progress πŸ—οΈ in Quansight <> Anaconda 2025 Apr 22, 2025
@jaimergp jaimergp marked this pull request as ready for review April 22, 2025 17:34
@jaimergp jaimergp requested a review from a team as a code owner April 22, 2025 17:34
@jjhelmus
Copy link
Contributor

Why use dict.fromkeys which requires an intermediate dict instance over set?

@jjhelmus
Copy link
Contributor

Answering my own question, set does not guarantee that the order of elements is preserved, dict.fromkeys does.

@jjhelmus
Copy link
Contributor

unique_iter from boltons.iterutils is another option as a replacement. Depends on if the goal is clarity or removing the use of boltons.

@github-project-automation github-project-automation bot moved this from πŸ†• New to βœ… Approved in πŸ”Ž Review Apr 22, 2025
@jaimergp
Copy link
Contributor Author

Depends on if the goal is clarity or removing the use of boltons.

I'm slowly trying to get rid of boltons when there are (now) Python idioms that maybe didn't exist back when the code was written. e.g. dict didn't have guaranteed insertion order til recently.

@jaimergp jaimergp merged commit 25e84ca into conda:main Apr 22, 2025
76 checks passed
@github-project-automation github-project-automation bot moved this from In Progress πŸ—οΈ to Done πŸ’ͺ🏾 in Quansight <> Anaconda 2025 Apr 22, 2025
@github-project-automation github-project-automation bot moved this from βœ… Approved to 🏁 Done in πŸ”Ž Review Apr 22, 2025
@kenodegard
Copy link
Contributor

I'm 100% on board with this, just FYI we also have conda.common.iterators.unique

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed [bot] added once the contributor has signed the CLA

Projects

Archived in project
Archived in project

Development

Successfully merging this pull request may close these issues.

4 participants