You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+11-8Lines changed: 11 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -67,24 +67,27 @@ p(20)
67
67
# returns 36
68
68
```
69
69
70
-
### pipe with thread/process and multiprocessing
70
+
### pipe with parallelism
71
71
72
-
You can have a function running in a seperate thread with pipe. Just put it in a `[]` or more explicitly `t[]`.
72
+
By default, pipe works with green threads which is based on event loop.
73
73
74
-
Because of the notorious GIL(Global Interpret Lock) of Python, people may want processes instead of threads. Just put a function in `p[]`.
74
+
You can have a function running in a seperate green thread with pipe. Just put it in a `[]` or more explicitly `g[]`. Multithreads or multiprocesses are also available.
75
75
76
76
```python
77
-
from syntax_sugar import thread_syntax as t, process_syntax as p
77
+
from syntax_sugar import (green_thread_syntax as g,
78
+
thread_syntax as t,
79
+
process_syntax as p)
78
80
79
-
pipe(10) | [print] |END# print run in a thread
81
+
pipe(10) | [print] |END# print run in a green thread
82
+
pipe(10) | g[print] |END# print run in a green thread
80
83
pipe(10) | t[print] |END# print run in a thread
81
84
pipe(10) | p[print] |END# print run in a process
82
85
```
83
86
84
-
What makes this syntax good is that you can specify how many threads you want to spawn, by doing `[function] * n` where `n` is the number of threads.
87
+
What makes this syntax good is that you can specify how many green threads you want to spawn, by doing `[function] * n` where `n` is the number of green threads.
85
88
86
89
```python
87
-
pipe([1,2,3,4,5]) | [print] *3|END# print will run in a ThreadPool of size 3
90
+
pipe([1,2,3,4,5]) | [print] *3|END# print will run in a GreenThreadPool of size 3
88
91
```
89
92
90
93
Here is an example of requesting a list of urls in parallel
@@ -93,7 +96,7 @@ Here is an example of requesting a list of urls in parallel
0 commit comments