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

Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdfChristopherTHyatt
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 

Recently uploaded (20)

Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdf
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 

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