Skip to content
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

Avoid explicit loop when updating OrderedSet #7857

Merged
merged 1 commit into from
May 25, 2023

Conversation

Illviljan
Copy link
Contributor

@Illviljan Illviljan commented May 21, 2023

Following recommendation from: #7824 (comment)

# main:
a = tuple(f"dim_{i}" for i in range(500))
%timeit OrderedSet(a)
46 µs ± 2.26 µs per loop (mean ± std. dev. of 7 runs, 10000 loops each)

# This PR:
a = tuple(f"dim_{i}" for i in range(500))
%timeit OrderedSet(a)
28.9 µs ± 476 ns per loop (mean ± std. dev. of 7 runs, 10000 loops each)

@Illviljan Illviljan added run-benchmark Run the ASV benchmark workflow topic-performance labels May 21, 2023
@Illviljan Illviljan mentioned this pull request May 21, 2023
6 tasks
Copy link
Collaborator

@mathause mathause left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As we are 3.9+ I think we could now do

self._d =| dict.fromkeys(values)

but no need to update.

@Illviljan Illviljan added the plan to merge Final call for comments label May 24, 2023
@Illviljan Illviljan merged commit 95bb813 into pydata:main May 25, 2023
dstansby pushed a commit to dstansby/xarray that referenced this pull request Jun 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
plan to merge Final call for comments run-benchmark Run the ASV benchmark workflow topic-performance
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants