Python stands to lose its GIL, and gain a lot of speed


One of Python’s long-standing weaknesses, its inability to scale well in multithreaded environments, is the target of a new proposal among the core developers of the popular programming language.

Developer Sam Gross has proposed a major change to the Global Interpreter Lock, or GIL—a key component in CPython, the reference implementation of Python.

If accepted, Gross’s proposal would rewrite the way Python serializes access to objects in its runtime from multiple threads, and would boost multithreaded performance significantly.

The GIL has long been seen as an obstacle to better multithreaded performance in CPython (and thus Python generally). Many efforts have been made to remove it over the years, but at the cost of hurting single-threaded performance—in other words, by making the vast majority of existing Python applications slower.

Python’s current metaphors for dealing with threading and multiprocessing don’t make it impossible to achieve high parallelism. But they make it hard enough that developers often turn to third-party modules like Dask to get that job done.

The new proposal makes changes to the way reference counting works for Python objects, so that references from the thread that owns an object are handled differently from those coming from other threads.

Copyright © 2021 IDG Communications, Inc.



Source link