[Python-Dev] Re: Proliferation of tstate arguments.

2020-03-17 Thread Steve Dower
On 17Mar2020 1803, Chris Angelico wrote: On Wed, Mar 18, 2020 at 3:50 AM Mark Shannon wrote: The accessibility of a thread-local variable is a strict superset of that of a function-local variable. Therefore storing the thread state in a thread-local variable is at least as capable as passing

[Python-Dev] Re: Proliferation of tstate arguments.

2020-03-17 Thread Chris Angelico
On Wed, Mar 18, 2020 at 3:50 AM Mark Shannon wrote: > The accessibility of a thread-local variable is a strict superset of > that of a function-local variable. > > Therefore storing the thread state in a thread-local variable is at > least as capable as passing thread-state as a parameter. > And

[Python-Dev] Changing layout of f_localsplus in frame objects

2020-03-17 Thread Skip Montanaro
(Apologies if you're seeing this twice. I first posted to the discourse instance.) I first worked on a register-based virtual machine in the 1.5.2 timeframe. That was before PEP 227 (closures) landed. Prior to that, local variables and the stack were contiguous in the f_localsplus array. Based on

[Python-Dev] Re: Proliferation of tstate arguments.

2020-03-17 Thread Mark Shannon
On 17/03/2020 3:38 pm, Steve Dower wrote: On 17Mar2020 1447, Mark Shannon wrote: On 16/03/2020 3:04 pm, Victor Stinner wrote: In short, the answer is yes. I said "no" then and gave reasons. AFAICT no one has faulted my reasoning. I said "yes" then and was also not faulted. I'll do

[Python-Dev] Re: Proliferation of tstate arguments.

2020-03-17 Thread Victor Stinner
Le mar. 17 mars 2020 à 15:49, Mark Shannon a écrit : > > * https://bugs.python.org/issue10915 > > * https://bugs.python.org/issue15751 > > > > It's unclear to me if fixing this issue would require to add a lock, > > nor if it would make PyGILState_GetThisThreadState() or > > _PyThreadState_GET()

[Python-Dev] Re: Proliferation of tstate arguments.

2020-03-17 Thread Victor Stinner
Le mar. 17 mars 2020 à 15:47, Mark Shannon a écrit : > > There is no PEP but scatted documents. I wrote a short article to > > elaborate the context of this work: > > https://vstinner.github.io/cpython-pass-tstate.html > > > > One motivation is to ease the implementation of subinterpreters (PEP >

[Python-Dev] Re: Proliferation of tstate arguments.

2020-03-17 Thread Steve Dower
On 17Mar2020 1447, Mark Shannon wrote: On 16/03/2020 3:04 pm, Victor Stinner wrote: In short, the answer is yes. I said "no" then and gave reasons. AFAICT no one has faulted my reasoning. I said "yes" then and was also not faulted. Let me reiterate why using a thread-local variable is

[Python-Dev] Re: Proliferation of tstate arguments.

2020-03-17 Thread Antoine Pitrou
On Tue, 17 Mar 2020 14:47:19 + Mark Shannon wrote: > On 16/03/2020 3:04 pm, Victor Stinner wrote: > > Hi, > > > >> Changes on this scale merit a PEP and proper discussion, rather than > >> being added piecemeal without proper review. > > > > Last November, I asked explicitly on

[Python-Dev] Re: Proliferation of tstate arguments.

2020-03-17 Thread Mark Shannon
On 16/03/2020 6:21 pm, Victor Stinner wrote: There were quick discussions about using thread local storage (TLS) to get and set the current Python thread state ("tstate"), instead of reading/setting an atomic variable (_PyRuntime.gilstate.tstate_current). In fact, TLS already exists as

[Python-Dev] Re: Proliferation of tstate arguments.

2020-03-17 Thread Mark Shannon
On 16/03/2020 3:04 pm, Victor Stinner wrote: Hi, Changes on this scale merit a PEP and proper discussion, rather than being added piecemeal without proper review. Last November, I asked explicitly on python-dev if we should "Pass the Python thread state to internal C functions":