Skip to content

Commit 32f1b49

Browse files
committed
updated
1 parent f0ecae6 commit 32f1b49

2 files changed

Lines changed: 45 additions & 23 deletions

File tree

README.md

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,27 @@
22

33
Make multi-threaded concurrency backward- and forward-compatible for the free-threaded future of Python.
44

5-
|Interpreter |Threading |Duration|
5+
6+
### Multi-Threading In and Out of Free-Threading
7+
8+
The following is a table of performance results for the execution of a function across each row of NumPy array, with `python3.14t` and `python3.14`, and with and without using a `ThreadPoolExecutor`. Performance improves with `python3.14t` but degrades with `python3.14`.
9+
10+
|Interpreter |Executor |Duration|
611
|------------|------------------------------|--------|
7-
|python3.14t |None |0.577 |
8-
|python3.14t |ThreadPoolExecutor |0.34 |
9-
|python3.14t |ConditionalThreadPoolExecutor |0.339 |
10-
|python3.14 |None |0.544 |
11-
|python3.14 |ThreadPoolExecutor |2.231 |
12-
|python3.14 |ConditionalThreadPoolExecutor |0.532 |
12+
|python3.14t |None |🟡 0.577 |
13+
|python3.14t |ThreadPoolExecutor |🟢 0.34 |
14+
|python3.14 |None |🟡 0.544 |
15+
|python3.14 |ThreadPoolExecutor |🔴 2.231 |
16+
17+
`ConditionalThreadPoolExecutor` lets a single interface get the best result in both contexts.
18+
19+
|Interpreter |Executor |Duration|
20+
|------------|------------------------------|--------|
21+
|python3.14t |None |🟡 0.577 |
22+
|python3.14t |ConditionalThreadPoolExecutor |🟢 0.339 |
23+
|python3.14 |None |🟡 0.544 |
24+
|python3.14 |ConditionalThreadPoolExecutor |🟡 0.532 |
25+
1326

1427
### Introduction
1528

performance/table.py

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,32 @@
11
import static_frame as sf
22

3-
if __name__ == '__main__':
4-
f = sf.Frame.from_records([
5-
['python3.14t', 'None', 0.577],
6-
['python3.14t', 'ThreadPoolExecutor', 0.340],
7-
['python3.14t', 'ConditionalThreadPoolExecutor', 0.339],
8-
['python3.14', 'None', 0.544],
9-
['python3.14', 'ThreadPoolExecutor', 2.231],
10-
['python3.14', 'ConditionalThreadPoolExecutor', 0.532],
11-
],
12-
columns=['Interpreter', 'Threading', 'Duration'],
13-
)
143

4+
def duration_with_emoji(val: float) -> str:
5+
if val < 0.5:
6+
emoji = '🟢'
7+
elif val < 1.0:
8+
emoji = '🟡'
9+
else:
10+
emoji = '🔴'
11+
return f'{emoji} {val}'
12+
13+
14+
if __name__ == '__main__':
15+
f = sf.FrameGO.from_records(
16+
[
17+
['python3.14t', 'None', 0.577],
18+
['python3.14t', 'ThreadPoolExecutor', 0.340],
19+
['python3.14t', 'ConditionalThreadPoolExecutor', 0.339],
20+
['python3.14', 'None', 0.544],
21+
['python3.14', 'ThreadPoolExecutor', 2.231],
22+
['python3.14', 'ConditionalThreadPoolExecutor', 0.532],
23+
],
24+
columns=['Interpreter', 'Executor', 'Duration'],
25+
)
26+
f = f.assign['Duration'](f['Duration'].iter_element().apply(duration_with_emoji))
1527

1628
config = sf.DisplayConfig(
17-
type_color=False,
18-
type_show=False,
19-
include_index=False,
20-
cell_max_width=100.
29+
type_color=False, type_show=False, include_index=False, cell_max_width=100.0
2130
)
2231

23-
print(f.to_markdown(config))
32+
print(f.to_markdown(config))

0 commit comments

Comments
 (0)