Skip to content

Commit dd5e217

Browse files
committed
docs: definition template
1 parent 16bed55 commit dd5e217

7 files changed

Lines changed: 71 additions & 23 deletions

File tree

2_standard_library/17_concurrent_execution/1_threading.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ def thread:
88
- intuition: ???
99

1010
- properties:
11-
- specification:
11+
- specification:
1212
- high level: https://docs.python.org/3.11/library/threading.html
1313
- low level: https://docs.python.org/3.11/library/_thread.html#module-_thread
1414
- implementation: https://github.com/python/cpython/blob/main/Lib/threading.py
@@ -21,9 +21,9 @@ def thread:
2121
- multiple IO-bound tasks:
2222
- database calls
2323
- external network services calls
24-
25-
- proof: None. It is a definition.
26-
24+
25+
- proof: none. it is a definition.
26+
2727
References: ???
2828

2929

2_standard_library/17_concurrent_execution/2_multiprocessing.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ def multiprocessing:
77

88
- intuition: threading API applied to processes.
99

10-
- properties:
10+
- properties:
1111
- specification: https://docs.python.org/3.11/library/multiprocessing.html
1212
- implementation:
1313
- high level: https://github.com/python/cpython/tree/main/Lib/multiprocessing
@@ -16,7 +16,7 @@ def multiprocessing:
1616

1717
- use cases: ???
1818

19-
- proof: None. It is a definition.
19+
- proof: none. it is a definition.
2020

2121
References: ???
2222

2_standard_library/4_built_in_types/5_iterator_types/1_iterator.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,19 @@ def iterator:
1212
- iterator protocol: https://docs.python.org/3/c-api/iter.html
1313
- types:
1414
- sequence iterator
15-
- callable object + sentinel value iterator
15+
- callable object + sentinel value iterator
1616
- specification: PEP 234 – Iterators. https://peps.python.org/pep-0234/
1717
- implementation: https://github.com/python/cpython/blob/main/Objects/iterobject.c
1818

1919
- forward and reserve traversal.
2020
- can only be traversed once.
21-
21+
2222
- examples: ???
2323

2424
- use cases: ???
25-
26-
- proof: None. It is a definition.
27-
25+
26+
- proof: none. it is a definition.
27+
2828
References:
2929
The Python Standard Library. 2025. https://docs.python.org/3/glossary.html#term-iterator
3030

2_standard_library/4_built_in_types/5_iterator_types/2_generator.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
def generator | generator function:
1+
def generator | generator function:
22
- formal: 𝑓: * ↦ Generator Iterator
33
- in words: a function that creates and returns a Generator Iterator.
44

@@ -18,8 +18,8 @@ def generator | generator function:
1818
- Just In Time processing: generate values as they become available and return them for processing them at call/client side.
1919
- create coroutines, which allows interleaving client code with library code:
2020
- this enables sequencing
21-
- proof: None. It is a definition.
22-
21+
- proof: none. it is a definition.
22+
2323
References:
2424
The Python Standard Library. 2025. https://docs.python.org/3/glossary.html#term-generator
2525

2_standard_library/4_built_in_types/5_iterator_types/3_generator_expression.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
def generator expression:
1+
def generator expression:
22
- formal: expression ↦ Iterator
33
- in words: an expression that returns an Iterator.
44

@@ -12,12 +12,12 @@
1212
- examples:
1313
1. without an if:
1414
i*i for i in range(10)
15-
2. with an if:
15+
2. with an if:
1616
j**j for j in range(20) if j%2 == 0
1717
- use cases: ???
18-
19-
- proof: None. It is a definition.
20-
18+
19+
- proof: none. it is a definition.
20+
2121
References:
2222
The Python Standard Library. 2025. https://docs.python.org/3/glossary.html#term-generator-iterator
2323

4_experiments/4_applications/math/is_prime.py

Lines changed: 51 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"""
99

1010

11-
def isPrime(n):
11+
def isPrime_1(n):
1212
for i in range(2, n):
1313
if n % i == 0:
1414
return False
@@ -17,7 +17,56 @@ def isPrime(n):
1717

1818
def main():
1919
for n in range(100):
20-
print(n, "is a prime:", isPrime(n))
20+
print(n, "is a prime:", isPrime_1(n))
2121

2222

2323
main()
24+
25+
26+
27+
####
28+
29+
"""
30+
Complexity
31+
N == number
32+
33+
O(N * (N - 1))
34+
O(N^2 - N)
35+
=> O(N^2)
36+
37+
"""
38+
39+
40+
def isPrime_2(number):
41+
if number > 1:
42+
for i in range(1, number):
43+
for j in range(2, number):
44+
if i * j == number:
45+
return False
46+
return True
47+
48+
49+
print(isPrime_2(4))
50+
print(isPrime_2(5))
51+
52+
"""
53+
N == number
54+
Complexity
55+
O(N - 1)
56+
=> 𝑂(𝑁)
57+
prime? == is it divisble by number >= 1 and < number
58+
59+
Is it divisible by any other number expect 1 and itself
60+
hence range 2 to number - 1
61+
"""
62+
63+
64+
def isPrime_3(number):
65+
for i in range(2, number):
66+
if number % i == 0:
67+
return False
68+
return True
69+
70+
71+
print(isPrime_3(4))
72+
print(isPrime_3(5))

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
- [Python](https://peps.python.org/pep-0007/)
1111
- [C](https://peps.python.org/pep-0007/)
1212
- [Annotations on the actual interpreter implementation](https://github.com/praisetompane/python_implementation_study_cpython)
13-
- They are prefixed with "Praise:"
13+
- They are prefixed with "Praise:"
1414
- Python's design, implementation and ecosystem.
1515

1616
## Language Details
@@ -29,7 +29,6 @@
2929
- [pip](https://pip.pypa.io/en/stable/)
3030
- [pipenv](https://pipenv.pypa.io/en/latest/)
3131
- [Structuring Projects](https://setuptools.pypa.io/en/stable/userguide/package_discovery.html#src-layout)
32-
3332
- [Extending and Embedding](https://docs.python.org/3/extending/index.html)
3433
- [PEP Index](https://www.python.org/dev/peps/)
3534
- [Developer Contribution Guide](https://devguide.python.org/)

0 commit comments

Comments
 (0)