On Thu, Aug 26, 2021 at 2:31 AM Nick Coghlan <ncogh...@gmail.com> wrote:
> On Thu, 26 Aug 2021 at 18:29, Nick Coghlan <ncogh...@gmail.com> wrote: > [Guido wrote] > > > PS. The mapping from varname to position should be on the code object, > not on the frame. This is how Mark does it (though his implementation would > need to be extended to take cells into account). > > > > It's taking cells into account that forces the lookup mapping to be on > > the frame: different executions of the same code object may reference > > different cell objects. > > Technically, if you design the fast refs mapping so that even cell > references have to do an indirection through the fast locals array, > then you can put the name-to-fast-locals-offset mapping on the code > object. Mine doesn't do that though, it references the cells directly > instead. > > I don't think it makes much difference in practice though, and I don't > like the idea of storing a lazily initialised cache on nominally > immutable code objects. > Only the part visible to the user is immutable. The specializing interpreter stores all sorts of internal mutable data on there -- and at least since 3.9 we've had the inline cache stored there. So as long as this mapping is invisible to the user, please let's put it on the code object -- we have a lot more frame objects than code objects, so saving a pointer on the frame object and adding it to the code object is advantageous. The cost of the extra indirection is irrelevant, this is always going to be a slow interface meant for occasional use in a debugger. -- --Guido van Rossum (python.org/~guido) *Pronouns: he/him **(why is my pronoun here?)* <http://feministing.com/2015/02/03/how-using-they-as-a-singular-pronoun-can-change-the-world/>
_______________________________________________ Python-Dev mailing list -- python-dev@python.org To unsubscribe send an email to python-dev-le...@python.org https://mail.python.org/mailman3/lists/python-dev.python.org/ Message archived at https://mail.python.org/archives/list/python-dev@python.org/message/CXGSRPRQMERDHE6KRDQJVTR46ZV5ED4P/ Code of Conduct: http://python.org/psf/codeofconduct/