Reference Counting's Performance Cost: Atomic Operations

Every creation, assignment, and deletion of an object in Python typically involves incrementing or decrementing its reference count. These operations, especially in 'hot loops' or with numerous temporary objects, add a performance overhead as they often need to be atomic to ensure thread safety, even in CPython with the Global Interpreter Lock (GIL) limiting true parallelism.

Sources

Open the full topic