Title: Logically merge cell and locals array. They are already contiguous in memory
Type: performance Stage: patch review
Components: Interpreter Core Versions:
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Mark.Shannon Nosy List: Guido.van.Rossum, Mark.Shannon, rhettinger, serhiy.storchaka
Priority: normal Keywords: patch

Created on 2021-04-01 11:33 by Mark.Shannon, last changed 2021-04-05 19:48 by serhiy.storchaka.

Pull Requests
URL Status Linked Edit
PR 25152 open Mark.Shannon, 2021-04-02 13:56
Messages (4)
msg389974 - (view) Author: Mark Shannon (Mark.Shannon) * (Python committer) Date: 2021-04-01 11:33
In the interpreter and compiler, the "fast" locals array and cells array are treated separately. By merging them in the compiler, the interpreter can be simplified a bit.
msg390069 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2021-04-02 15:09
This doesn't look simpler to me.  We will forever lose mental clock cycles disentangling the locals and cells.  So, I don't think they should be commingled.
msg390247 - (view) Author: Guido van Rossum (Guido.van.Rossum) Date: 2021-04-05 18:44
To me it looks simpler though. The locals and cells are already stored in a single array, f_localsplus (which also contains the evaluation stack). There are various complications in ceval.c to translate cell indexes to indexes in this array (ein particular the extra local variable 'freevars', which weighs down the stack frame).

Making the interpreter simpler by moving things to the compiler also makes it easier for the C compiler to optimize the code of the interpreter better.
msg390253 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2021-04-05 19:48
Date User Action Args
2021-04-05 19:48:29serhiy.storchakasetnosy: + serhiy.storchaka
messages: + msg390253
2021-04-05 18:44:58Guido.van.Rossumsetnosy: + Guido.van.Rossum
messages: + msg390247
2021-04-02 15:09:54rhettingersetnosy: + rhettinger
messages: + msg390069
2021-04-02 13:56:29Mark.Shannonsetkeywords: + patch
stage: needs patch -> patch review
pull_requests: + pull_request23899
2021-04-01 11:33:50Mark.Shannoncreate