We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent da6ba80 commit 4de6a76Copy full SHA for 4de6a76
determenistic/__init__.py
determenistic/determtic.py
@@ -0,0 +1,24 @@
1
+import collections
2
+import functools
3
+import time
4
+
5
6
+@functools.lru_cache(maxsize=200)
7
+def count_words(sentence):
8
+ _count = collections.Counter()
9
+ for w in str(sentence).split():
10
+ _count[w] += 1
11
+ return _count
12
13
14
+if __name__ == "__main__":
15
16
+ sen = """In mathematics, computer science and physics,
17
+ a deterministic system is a system in which no
18
+ randomness is involved in the development of future states of the system"""
19
20
+ for i in range(3):
21
+ start_time = time.perf_counter()
22
+ count = count_words(sen)
23
+ stop_time = time.perf_counter()
24
+ print("Exec #{} time: {:.9f}".format(i, stop_time-start_time))
0 commit comments