Skip to Content
Software Architecture with Python
book

Software Architecture with Python

by Anand Balachandran Pillai
April 2017
Intermediate to advanced
556 pages
11h 5m
English
Packt Publishing
Content preview from Software Architecture with Python

Multithreading – Python and GIL

In Python there is, a global lock that prevents multiple threads from executing native bytecode at once. This lock is required, since the memory management of CPython (the native implementation of Python) is not thread-safe.

This lock is called Global Interpreter Lock or just GIL.

Python cannot execute bytecode operations concurrently on CPUs due to the GIL. Hence, Python becomes almost unsuitable for the following cases:

  • When the program depends on a number of heavy bytecode operations, which it wants to run concurrently
  • When the program uses multithreading to utilize the full power of multiple CPU cores on a single machine

I/O calls and long-running operations typically occur outside the GIL. Therefore, multithreading ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Architecture Patterns with Python

Architecture Patterns with Python

Harry Percival, Bob Gregory

Publisher Resources

ISBN: 9781786468529Supplemental Content