Skip to content

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