From cc3eb36f922cf1f2a99fd88f4ce5bc4f0cc43347 Mon Sep 17 00:00:00 2001 From: Satwik Kansal Date: Wed, 6 Sep 2017 16:20:54 +0530 Subject: [PATCH] Minor Examples: Update explanation for multithreading example * Clarifies that Python threads do run concurrently and are useful for I/O bound tasks. Fixes https://github.com/satwikkansal/wtfpython/issues/30 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 310acd1..5fe7066 100755 --- a/README.md +++ b/README.md @@ -1661,7 +1661,7 @@ a, b = a[b] = {}, 5 print(dis.dis(f)) ``` -* 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. +* 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. * List slicing with out of the bounds indices throws no errors ```py