Skip to content

Use 'in' instead of 'find()' in tidy.py #21377

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

Merged
merged 1 commit into from
Jan 21, 2015
Merged

Use 'in' instead of 'find()' in tidy.py #21377

merged 1 commit into from
Jan 21, 2015

Conversation

iKevinY
Copy link
Contributor

@iKevinY iKevinY commented Jan 18, 2015

x in y is more Pythonic than y.find(x) != -1. I believe it runs quite a bit faster as well (though it's probably not a bottleneck of the Travis builds):

$ python -m timeit '"abc".find("a") != -1'
1000000 loops, best of 3: 0.218 usec per loop
$ python -m timeit '"a" in "abc"'
10000000 loops, best of 3: 0.0343 usec per loop

'x in y' is more Pythonic and faster than 'y.find(x) != -1'.
@rust-highfive
Copy link
Contributor

r? @nikomatsakis

(rust_highfive has picked a reviewer for you, use r? to override)

@huonw huonw assigned huonw and unassigned nikomatsakis Jan 19, 2015
@alexcrichton
Copy link
Member

@bors: r=huonw 21f4483 rollup

alexcrichton added a commit to alexcrichton/rust that referenced this pull request Jan 19, 2015
`x in y` is more Pythonic than `y.find(x) != -1`. I believe it runs quite a bit faster as well (though it's probably not a bottleneck of the Travis builds):

```bash
$ python -m timeit '"abc".find("a") != -1'
1000000 loops, best of 3: 0.218 usec per loop
$ python -m timeit '"a" in "abc"'
10000000 loops, best of 3: 0.0343 usec per loop
```
barosl added a commit to barosl/rust that referenced this pull request Jan 20, 2015
`x in y` is more Pythonic than `y.find(x) != -1`. I believe it runs quite a bit faster as well (though it's probably not a bottleneck of the Travis builds):

```bash
$ python -m timeit '"abc".find("a") != -1'
1000000 loops, best of 3: 0.218 usec per loop
$ python -m timeit '"a" in "abc"'
10000000 loops, best of 3: 0.0343 usec per loop
```
@bors bors merged commit 21f4483 into rust-lang:master Jan 21, 2015
@iKevinY iKevinY deleted the speedy-tidy branch January 21, 2015 06:04
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.

6 participants