[Python-ideas] Briefer string format

Steve Dower Steve.Dower at microsoft.com
Tue Jul 21 04:10:31 CEST 2015


I'd rather keep the transform as simple as possible. If text formatting is your bottleneck, congratulations on fixing your network, disk, RAM and probably your users.

Those who need to micro-optimize this code can do what you suggested by hand - there's no need for us to make our lives more complicated for the straw man who has a string formatting bottleneck and doesn't know enough to research another approach.

Cheers,
Steve

Top-posted from my Windows Phone
________________________________
From: Alexander Belopolsky<mailto:alexander.belopolsky at gmail.com>
Sent: ‎7/‎20/‎2015 18:40
To: Eric V. Smith<mailto:eric at trueblade.com>
Cc: python-ideas<mailto:python-ideas at python.org>
Subject: Re: [Python-ideas] Briefer string format


On Mon, Jul 20, 2015 at 4:20 PM, Eric V. Smith <eric at trueblade.com<mailto:eric at trueblade.com>> wrote:
And thinking about it yet some more, I think the easiest and most
consistent thing to do would be to translate it like:

f'{a[0]}{b[c]}' == '{[0]}{[c]}'.format(a, b)

I think Python can do more at compile time and translate

f"Result1={expr1:fmt1};Result2={expr2:fmt2}"

to bytecode equivalent of

"Result1=%s;Result2=%s" % ((expr1).__format__(fmt1), (expr2).__format__(fmt2))

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20150721/fa1fce50/attachment.html>


More information about the Python-ideas mailing list