A viable solution for Python concurrency
A viable solution for Python concurrency
Posted Oct 19, 2021 11:12 UTC (Tue) by njs (subscriber, #40338)In reply to: A viable solution for Python concurrency by tialaramex
Parent article: A viable solution for Python concurrency
In this case the extra reads are pretty cheap, because the relevant cache lines can be kept loaded in "shared" state (in the MESI sense), and the branches are predictable. OTOH if reads had to acquire a lock, that would trigger cache line bouncing and be *very* expensive.
Python modules and classes are mutable data structures that are almost always read, rather than mutated. So this pattern of heavy cross-thread read-traffic to a mostly-immutable object is ubiquitous in python, so it makes sense to optimize for it.
           