[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Python-Dev] [PEP 558] thinking through locals() semantics

On Sun, Jun 02, 2019 at 11:52:02PM +1200, Greg Ewing wrote:
> Armin Rigo wrote:
> >You have the occasional big function that benefits a lot from being
> >JIT-compiled but which contains ``.format(**locals())``.
> There should be a lot less need for that now that we have f-strings.

I think you're forgetting that a lot of code (especially libraries) 
either have to support older versions of Python, and so cannot use 
f-strings at all, or was written using **locals before f-strings came 
along, and hasn't been touched since.

Another case where f-strings don't help is when the template is 
dynamically generated.

It may be that there will be less new code written using **locals() but 
I don't think that the **locals() trick will disappear any time before 
Python 5000.