Skip to content

Commit cc3eb36

Browse files
committed
Minor Examples: Update explanation for multithreading example
* Clarifies that Python threads do run concurrently and are useful for I/O bound tasks. Fixes satwikkansal#30
1 parent 24c4a64 commit cc3eb36

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1661,7 +1661,7 @@ a, b = a[b] = {}, 5
16611661
print(dis.dis(f))
16621662
```
16631663

1664-
* Multiple Python threads don't run concurrently (yes you heard it right!). It may seem intuitive to spawn several threads and let them execute concurrently, but, because of the Global Interpreter Lock in Python, all you're doing is making your threads execute on the same core turn by turn. To achieve actual parallelization in Python, you might want to use the Python [multiprocessing](https://docs.python.org/2/library/multiprocessing.html) module.
1664+
* Multiple Python threads won't run your *Python code* concurrently (yes you heard it right!). It may seem intuitive to spawn several threads and let them execute your Python code concurrently, but, because of the [Global Interpreter Lock](https://wiki.python.org/moin/GlobalInterpreterLock) in Python, all you're doing is making your threads execute on the same core turn by turn. Python threads are good for IO-bound tasks, but to achieve actual parallelization in Python for CPU-bound tasks, you might want to use the Python [multiprocessing](https://docs.python.org/2/library/multiprocessing.html) module.
16651665

16661666
* List slicing with out of the bounds indices throws no errors
16671667
```py

0 commit comments

Comments
 (0)