Skip to content

Conversation

@chrisyeh96
Copy link

@chrisyeh96 chrisyeh96 commented May 21, 2025

Python's built-in sorted() function always returns a list. Therefore, there is no need to call list(sorted(...)) or sorted(list(...)). Simply calling sorted(...) is sufficient.

@pytorch-bot
Copy link

pytorch-bot bot commented May 21, 2025

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/vision/9078

Note: Links to docs will display an error until the docs builds have been completed.

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@chrisyeh96 chrisyeh96 changed the title Remove unnecessary list() calls after sorted() Remove unnecessary list() calls before/after sorted() May 21, 2025
@NicolasHug
Copy link
Member

Thanks for the PR @chrisyeh96 . You're probably right that these calls to list() aren't needed. They're don't really add any cost either and aren't in a hot path, so I'm inclined to just leave them there. These parts of the code base (datasets) aren't actively developed

@NicolasHug NicolasHug closed this May 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants