
Le sam. 16 nov. 2019 à 20:55, Neil Schemenauer <nas-python@arctrix.com> a écrit :
If you use threadstate often, passing it explicitly (which likely uses a CPU register) could be a win. If you use it rarely, that CPU register would be better utilized for passing function arguments you actually use.
Currently, I would say that it's used "rarely". But. If we want to implement subinterpreters, we have to use way more often. Since each interpreter must have its isolated namespace, I expect that even 1+1 should use tstate to get the 2 "singleton" from its private namespace, rather than using a "global" singleton. Basically, all builtin types and all builtin modules should be modified to have one namespace per interpreter. For C extensions, it's an old project to have a "state" passed to module functions, and so be able to have 2 separated instances of the same C extension, rather than having a single global namespace. Examples: https://www.python.org/dev/peps/pep-0489/ https://www.python.org/dev/peps/pep-0573/ I would like to implement subinterpreters. IMHO the project is feasible and if it works, it would make Python more competitive with other programming languages! IMHO fixing the C API (or write a new one) and subinterpreters are the only two most feasible and most realistic projects to optimize CPython right now. Victor -- Night gathers, and now my watch begins. It shall not end until my death.