SlideShare a Scribd company logo
1 of 21
Download to read offline
GIL (Global Interpreter Lock)
Concurrency & Parallelism in Python
GIL - CONCURRENCY & PARALLELISM IN PYTHON 1
Piyus Gupta
Sat, 20th May 2017
BangPypers @ vmware India
Contents:
 Some sample code before we drill GIL
 Thread Analogy
 CPU Scheduling
 Python Threads
 What is GIL ? And why is it needed ?
 High CPU usage with multithreading vs multiprocessing
 Can we really remove GIL ?
GIL - CONCURRENCY & PARALLELISM IN PYTHON 2
Single Threaded
GIL - CONCURRENCY & PARALLELISM IN PYTHON 3
Multi Threaded
GIL - CONCURRENCY & PARALLELISM IN PYTHON 4
CPU Scheduling
GIL - CONCURRENCY & PARALLELISM IN PYTHON 5
Threads vs Process
GIL - CONCURRENCY & PARALLELISM IN PYTHON 6
Python Threads
Python threads are real system threads
POSIX threads (pthreads ) on Unix
Windows threads
Fully managed by host operating system
Represents threaded execution of the Python interpreter process
(written in C)
GIL - CONCURRENCY & PARALLELISM IN PYTHON 7
What is Thread Safe ?
A piece of code is thread-safe if it functions correctly during
simultaneous execution by multiple threads.
It must satisfy the need for multiple threads to access the same
shared data, and the need for a shared piece of data to be
accessed by only one thread at any given time.
GIL - CONCURRENCY & PARALLELISM IN PYTHON 8
GIL Basics
Parallel execution is forbidden
There is a "global interpreter lock"
The GIL ensures that only one thread runs in the interpreter at
once
Simplifies many low-level details (memory management, callouts
to C extensions, etc.)
GIL - CONCURRENCY & PARALLELISM IN PYTHON 9
Mutual Exclusion
GIL - CONCURRENCY & PARALLELISM IN PYTHON 10
GIL working strategy
GIL - CONCURRENCY & PARALLELISM IN PYTHON 11
CPU Bound Task
GIL - CONCURRENCY & PARALLELISM IN PYTHON 12
 CPU-bound threads that never perform I/O are handled as a
special case
 A "check" occurs every 100 "ticks“
 You can Change it using sys.setcheckinterval()
GIL - Visualized
GIL - CONCURRENCY & PARALLELISM IN PYTHON 13
Why GIL ?
Increased speed of single-threaded programs.
Easy integration of C libraries that usually are not thread-safe.
It is faster in the multi-threaded case for i/o bound programs.
GIL - CONCURRENCY & PARALLELISM IN PYTHON 14
Can’t we get rid of GIL ?
Back in the days of Python 1.5, Greg Stein actually implemented
a comprehensive patch that removed the GIL and replaced it with
fine-grained locking.
Unfortunately, even on Windows (where locks are very efficient)
this ran ordinary Python code about twice as slow as the
interpreter using the GIL.
On Linux the performance loss was even worse because pthread
locks aren’t as efficient.
GIL - CONCURRENCY & PARALLELISM IN PYTHON 15
GIL - CONCURRENCY & PARALLELISM IN PYTHON 16
But what about performance then ?
Conclusion
GIL - CONCURRENCY & PARALLELISM IN PYTHON 17
Only way to remove GIL !
GIL - CONCURRENCY & PARALLELISM IN PYTHON 18
References:
 http://www.dabeaz.com/GIL
 https://www.youtube.com/watch?v=Obt-vMVdM8s
 https://www.youtube.com/watch?v=SNBKWuM-Lu8
 https://randu.org/tutorials/threads/
Next Read:
 AsyncIO
 https://pymotw.com/3/concurrency.html
GIL - CONCURRENCY & PARALLELISM IN PYTHON 19
E-mail: piyusgupta01@gmail.com
GitHub: https://github.com/piyusgupta/juggler
GIL - CONCURRENCY & PARALLELISM IN PYTHON 20
GIL - CONCURRENCY & PARALLELISM IN PYTHON 21

More Related Content

Similar to GIL - Concurrency & Parallelism in Python

Python* Scalability in Production Environments
Python* Scalability in Production EnvironmentsPython* Scalability in Production Environments
Python* Scalability in Production EnvironmentsIntel® Software
 
How to Use Multi-thread & Multi-process in Python
How to Use Multi-thread & Multi-process in PythonHow to Use Multi-thread & Multi-process in Python
How to Use Multi-thread & Multi-process in PythonSpeedyCloud
 
Python performance engineering in 2017
Python performance engineering in 2017Python performance engineering in 2017
Python performance engineering in 2017Alex Chistyakov
 
Python 101 for the .NET Developer
Python 101 for the .NET DeveloperPython 101 for the .NET Developer
Python 101 for the .NET DeveloperSarah Dutkiewicz
 
Concurrency in Python
Concurrency in PythonConcurrency in Python
Concurrency in Pythonkonryd
 
Beating the (sh** out of the) GIL - Multithreading vs. Multiprocessing
Beating the (sh** out of the) GIL - Multithreading vs. MultiprocessingBeating the (sh** out of the) GIL - Multithreading vs. Multiprocessing
Beating the (sh** out of the) GIL - Multithreading vs. MultiprocessingGuy K. Kloss
 
Pyjion - a JIT extension system for CPython
Pyjion - a JIT extension system for CPythonPyjion - a JIT extension system for CPython
Pyjion - a JIT extension system for CPythonAnthony Shaw
 
Startup Camp - Git, Python, Django session
Startup Camp - Git, Python, Django sessionStartup Camp - Git, Python, Django session
Startup Camp - Git, Python, Django sessionJuraj Michálek
 
Supporting Java™ 9 in Eclipse - A critical perspective - Stephan Herrmann
Supporting Java™ 9 in Eclipse - A critical perspective - Stephan HerrmannSupporting Java™ 9 in Eclipse - A critical perspective - Stephan Herrmann
Supporting Java™ 9 in Eclipse - A critical perspective - Stephan HerrmannEclipse Day India
 
Building SciPy kernels with Pythran
Building SciPy kernels with PythranBuilding SciPy kernels with Pythran
Building SciPy kernels with PythranRalf Gommers
 
PyParis2018 - Python tooling for continuous deployment
PyParis2018 - Python tooling for continuous deploymentPyParis2018 - Python tooling for continuous deployment
PyParis2018 - Python tooling for continuous deploymentArthur Lutz
 
Understanding how concurrency work in os
Understanding how concurrency work in osUnderstanding how concurrency work in os
Understanding how concurrency work in osGenchiLu1
 
Reconfigurable ICs
Reconfigurable ICsReconfigurable ICs
Reconfigurable ICsAnish Goel
 
Euro python2011 High Performance Python
Euro python2011 High Performance PythonEuro python2011 High Performance Python
Euro python2011 High Performance PythonIan Ozsvald
 
Delivering Quality at Speed with GitOps
Delivering Quality at Speed with GitOpsDelivering Quality at Speed with GitOps
Delivering Quality at Speed with GitOpsWeaveworks
 
Python coroutine
Python coroutinePython coroutine
Python coroutine경섭 심
 
A Primer on FPGAs - Field Programmable Gate Arrays
A Primer on FPGAs - Field Programmable Gate ArraysA Primer on FPGAs - Field Programmable Gate Arrays
A Primer on FPGAs - Field Programmable Gate ArraysTaylor Riggan
 

Similar to GIL - Concurrency & Parallelism in Python (20)

Python* Scalability in Production Environments
Python* Scalability in Production EnvironmentsPython* Scalability in Production Environments
Python* Scalability in Production Environments
 
Intel python 2017
Intel python 2017Intel python 2017
Intel python 2017
 
How to Use Multi-thread & Multi-process in Python
How to Use Multi-thread & Multi-process in PythonHow to Use Multi-thread & Multi-process in Python
How to Use Multi-thread & Multi-process in Python
 
Python performance engineering in 2017
Python performance engineering in 2017Python performance engineering in 2017
Python performance engineering in 2017
 
Python 101 for the .NET Developer
Python 101 for the .NET DeveloperPython 101 for the .NET Developer
Python 101 for the .NET Developer
 
Concurrency in Python
Concurrency in PythonConcurrency in Python
Concurrency in Python
 
Beating the (sh** out of the) GIL - Multithreading vs. Multiprocessing
Beating the (sh** out of the) GIL - Multithreading vs. MultiprocessingBeating the (sh** out of the) GIL - Multithreading vs. Multiprocessing
Beating the (sh** out of the) GIL - Multithreading vs. Multiprocessing
 
Pyjion - a JIT extension system for CPython
Pyjion - a JIT extension system for CPythonPyjion - a JIT extension system for CPython
Pyjion - a JIT extension system for CPython
 
Startup Camp - Git, Python, Django session
Startup Camp - Git, Python, Django sessionStartup Camp - Git, Python, Django session
Startup Camp - Git, Python, Django session
 
Supporting Java™ 9 in Eclipse - A critical perspective - Stephan Herrmann
Supporting Java™ 9 in Eclipse - A critical perspective - Stephan HerrmannSupporting Java™ 9 in Eclipse - A critical perspective - Stephan Herrmann
Supporting Java™ 9 in Eclipse - A critical perspective - Stephan Herrmann
 
Building SciPy kernels with Pythran
Building SciPy kernels with PythranBuilding SciPy kernels with Pythran
Building SciPy kernels with Pythran
 
PyParis2018 - Python tooling for continuous deployment
PyParis2018 - Python tooling for continuous deploymentPyParis2018 - Python tooling for continuous deployment
PyParis2018 - Python tooling for continuous deployment
 
Understanding how concurrency work in os
Understanding how concurrency work in osUnderstanding how concurrency work in os
Understanding how concurrency work in os
 
Reconfigurable ICs
Reconfigurable ICsReconfigurable ICs
Reconfigurable ICs
 
Euro python2011 High Performance Python
Euro python2011 High Performance PythonEuro python2011 High Performance Python
Euro python2011 High Performance Python
 
Delivering Quality at Speed with GitOps
Delivering Quality at Speed with GitOpsDelivering Quality at Speed with GitOps
Delivering Quality at Speed with GitOps
 
Python coroutine
Python coroutinePython coroutine
Python coroutine
 
Work organization
Work organizationWork organization
Work organization
 
A Primer on FPGAs - Field Programmable Gate Arrays
A Primer on FPGAs - Field Programmable Gate ArraysA Primer on FPGAs - Field Programmable Gate Arrays
A Primer on FPGAs - Field Programmable Gate Arrays
 
QCon São Paulo 2018
QCon São Paulo 2018QCon São Paulo 2018
QCon São Paulo 2018
 

Recently uploaded

Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024BookNet Canada
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April  Automation LPDGAPIForce Zurich 5 April  Automation LPDG
APIForce Zurich 5 April Automation LPDGMarianaLemus7
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraDeakin University
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 

Recently uploaded (20)

Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April  Automation LPDGAPIForce Zurich 5 April  Automation LPDG
APIForce Zurich 5 April Automation LPDG
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning era
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 

GIL - Concurrency & Parallelism in Python

  • 1. GIL (Global Interpreter Lock) Concurrency & Parallelism in Python GIL - CONCURRENCY & PARALLELISM IN PYTHON 1 Piyus Gupta Sat, 20th May 2017 BangPypers @ vmware India
  • 2. Contents:  Some sample code before we drill GIL  Thread Analogy  CPU Scheduling  Python Threads  What is GIL ? And why is it needed ?  High CPU usage with multithreading vs multiprocessing  Can we really remove GIL ? GIL - CONCURRENCY & PARALLELISM IN PYTHON 2
  • 3. Single Threaded GIL - CONCURRENCY & PARALLELISM IN PYTHON 3
  • 4. Multi Threaded GIL - CONCURRENCY & PARALLELISM IN PYTHON 4
  • 5. CPU Scheduling GIL - CONCURRENCY & PARALLELISM IN PYTHON 5
  • 6. Threads vs Process GIL - CONCURRENCY & PARALLELISM IN PYTHON 6
  • 7. Python Threads Python threads are real system threads POSIX threads (pthreads ) on Unix Windows threads Fully managed by host operating system Represents threaded execution of the Python interpreter process (written in C) GIL - CONCURRENCY & PARALLELISM IN PYTHON 7
  • 8. What is Thread Safe ? A piece of code is thread-safe if it functions correctly during simultaneous execution by multiple threads. It must satisfy the need for multiple threads to access the same shared data, and the need for a shared piece of data to be accessed by only one thread at any given time. GIL - CONCURRENCY & PARALLELISM IN PYTHON 8
  • 9. GIL Basics Parallel execution is forbidden There is a "global interpreter lock" The GIL ensures that only one thread runs in the interpreter at once Simplifies many low-level details (memory management, callouts to C extensions, etc.) GIL - CONCURRENCY & PARALLELISM IN PYTHON 9
  • 10. Mutual Exclusion GIL - CONCURRENCY & PARALLELISM IN PYTHON 10
  • 11. GIL working strategy GIL - CONCURRENCY & PARALLELISM IN PYTHON 11
  • 12. CPU Bound Task GIL - CONCURRENCY & PARALLELISM IN PYTHON 12  CPU-bound threads that never perform I/O are handled as a special case  A "check" occurs every 100 "ticks“  You can Change it using sys.setcheckinterval()
  • 13. GIL - Visualized GIL - CONCURRENCY & PARALLELISM IN PYTHON 13
  • 14. Why GIL ? Increased speed of single-threaded programs. Easy integration of C libraries that usually are not thread-safe. It is faster in the multi-threaded case for i/o bound programs. GIL - CONCURRENCY & PARALLELISM IN PYTHON 14
  • 15. Can’t we get rid of GIL ? Back in the days of Python 1.5, Greg Stein actually implemented a comprehensive patch that removed the GIL and replaced it with fine-grained locking. Unfortunately, even on Windows (where locks are very efficient) this ran ordinary Python code about twice as slow as the interpreter using the GIL. On Linux the performance loss was even worse because pthread locks aren’t as efficient. GIL - CONCURRENCY & PARALLELISM IN PYTHON 15
  • 16. GIL - CONCURRENCY & PARALLELISM IN PYTHON 16 But what about performance then ?
  • 17. Conclusion GIL - CONCURRENCY & PARALLELISM IN PYTHON 17
  • 18. Only way to remove GIL ! GIL - CONCURRENCY & PARALLELISM IN PYTHON 18
  • 19. References:  http://www.dabeaz.com/GIL  https://www.youtube.com/watch?v=Obt-vMVdM8s  https://www.youtube.com/watch?v=SNBKWuM-Lu8  https://randu.org/tutorials/threads/ Next Read:  AsyncIO  https://pymotw.com/3/concurrency.html GIL - CONCURRENCY & PARALLELISM IN PYTHON 19
  • 21. GIL - CONCURRENCY & PARALLELISM IN PYTHON 21