pyo3/examples/word-count/README.md

54 lines
914 B
Markdown
Raw Normal View History

2017-07-23 05:32:18 +00:00
# word-count
2019-03-22 13:07:33 +00:00
Demonstrates searching for a file in plain python, with rust singlethreaded and with rust multithreaded.
2018-07-30 20:52:22 +00:00
2017-07-23 05:32:18 +00:00
## Build
2018-07-30 20:52:22 +00:00
```shell
2017-07-23 05:32:18 +00:00
python setup.py install
```
## Usage
```python
2021-02-24 18:41:45 +00:00
from word_count import search_py, search, search_sequential
2017-07-23 05:32:18 +00:00
2021-02-24 18:41:45 +00:00
search_py("foo bar", "foo")
search("foo bar", "foo")
search_sequential("foo bar", "foo")
2017-07-23 05:32:18 +00:00
```
2018-07-30 20:52:22 +00:00
## Benchmark
2018-12-28 19:29:12 +00:00
Install the depedencies:
```shell
pip install -r requirements-dev.txt
```
2018-07-30 20:52:22 +00:00
There is a benchmark in `tests/test_word_count.py`:
```shell
pytest -v tests
2018-10-09 16:21:52 +00:00
```
## Testing
2022-01-16 16:12:40 +00:00
To test install nox globally and run
2018-10-09 16:21:52 +00:00
```shell
2022-01-16 16:12:40 +00:00
nox
2018-12-28 19:29:12 +00:00
```
## Copying this example
Use [`cargo-generate`](https://crates.io/crates/cargo-generate):
```bash
$ cargo install cargo-generate
$ cargo generate --git https://github.com/PyO3/pyo3 examples/word-count
```
(`cargo generate` will take a little while to clone the PyO3 repo first; be patient when waiting for the command to run.)