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

Use str.replace in make_gaps_ambiguous #474

Merged
merged 1 commit into from
Mar 25, 2020

Conversation

groutr
Copy link
Contributor

@groutr groutr commented Mar 25, 2020

Description of proposed changes

This PR switches out the numpy based implementation for one that uses str.replace. Not only is it significantly faster, but it is also more memory efficient.

In [221]: %timeit make_gaps_ambiguous(a)
1.24 ms ± 27.1 µs per loop (mean ± std. dev. of 7 runs, 1000 loops each)

In [222]: %timeit str_replace(a)
7.78 µs ± 283 ns per loop (mean ± std. dev. of 7 runs, 100000 loops each)

Testing

Ran the two implementations on the same input (a case with no '-' characters and a case with '-' characters) and observed the same output.

@huddlej huddlej merged commit d2398eb into nextstrain:master Mar 25, 2020
@huddlej
Copy link
Contributor

huddlej commented Mar 25, 2020

Thanks, @groutr and @Zsailer!

@groutr groutr deleted the str_replace branch March 25, 2020 22:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants