trio
trio copied to clipboard
use of locals() / f_locals() foils pypy
Mutation via locals(), f_locals() causes pypy to abort traces with "force quasi-immut". Trio does this to manage KI protection state, and the most common API calls like current_time() are implicated. So pypy spends a lot of time compiling traces, only to abort them.
some ideas for fixing discussed on gitter starting at https://gitter.im/python-trio/general?at=6357f654cf41c67a5cc9b993
NOTE: a tracing JIT like PyPy is not going to do well anyway with async apps that have a high rate of context switches combined with heterogenous workloads, since the tracing will happen across context switches to other coroutines (which are arbitrarily occurring and arbitrarily ordered).