Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!
Available in Python 3.14+.
from concurrent.futures import InterpreterPoolExecutordef calculate_square(x):
return x * xwith InterpreterPoolExecutor() as executor:
numbers = range(100)
results = executor.map(calculate_square, numbers)
for number, squared in zip(numbers, results):
print(f"{number}^2 = {squared}")0^2 = 0
1^2 = 1
2^2 = 4
3^2 = 9
4^2 = 16
5^2 = 25
6^2 = 36
7^2 = 49
8^2 = 64
9^2 = 81
10^2 = 100
11^2 = 121
12^2 = 144
13^2 = 169
14^2 = 196
15^2 = 225
16^2 = 256
17^2 = 289
18^2 = 324
19^2 = 361
20^2 = 400
21^2 = 441
22^2 = 484
23^2 = 529
24^2 = 576
25^2 = 625
26^2 = 676
27^2 = 729
28^2 = 784
29^2 = 841
30^2 = 900
31^2 = 961
32^2 = 1024
33^2 = 1089
34^2 = 1156
35^2 = 1225
36^2 = 1296
37^2 = 1369
38^2 = 1444
39^2 = 1521
40^2 = 1600
41^2 = 1681
42^2 = 1764
43^2 = 1849
44^2 = 1936
45^2 = 2025
46^2 = 2116
47^2 = 2209
48^2 = 2304
49^2 = 2401
50^2 = 2500
51^2 = 2601
52^2 = 2704
53^2 = 2809
54^2 = 2916
55^2 = 3025
56^2 = 3136
57^2 = 3249
58^2 = 3364
59^2 = 3481
60^2 = 3600
61^2 = 3721
62^2 = 3844
63^2 = 3969
64^2 = 4096
65^2 = 4225
66^2 = 4356
67^2 = 4489
68^2 = 4624
69^2 = 4761
70^2 = 4900
71^2 = 5041
72^2 = 5184
73^2 = 5329
74^2 = 5476
75^2 = 5625
76^2 = 5776
77^2 = 5929
78^2 = 6084
79^2 = 6241
80^2 = 6400
81^2 = 6561
82^2 = 6724
83^2 = 6889
84^2 = 7056
85^2 = 7225
86^2 = 7396
87^2 = 7569
88^2 = 7744
89^2 = 7921
90^2 = 8100
91^2 = 8281
92^2 = 8464
93^2 = 8649
94^2 = 8836
95^2 = 9025
96^2 = 9216
97^2 = 9409
98^2 = 9604
99^2 = 9801