Open
Description
There's currently threading.RLock use in a few places strictly to have heapq use be safe under freethreading. This isn't a small penalty.
In 3.14+, this should be safe (double check at release, see: python/cpython#135036)
Options here include vendoring the 3.14 copy of the heapq module, implementing this natively with critical sections, dynamically importing versions of the code to only use the lock under freethreading + python < 3.14