pyo3/examples/word-count/word_count/__init__.py

18 lines
410 B
Python
Raw Normal View History

from .word_count import search, search_sequential, search_sequential_allow_threads
__all__ = [
"search_py",
"search",
"search_sequential",
"search_sequential_allow_threads",
]
def search_py(contents: str, needle: str) -> int:
total = 0
for line in contents.splitlines():
for word in line.split(" "):
2020-06-05 12:33:15 +00:00
if word == needle:
total += 1
return total