Author ztane
Recipients Demur Rumed, eric.smith, mjpieters, serhiy.storchaka, ztane
Date 2016-07-13.14:44:09
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1468421049.74.0.421102567667.issue27078@psf.upfronthosting.co.za>
In-reply-to
Content
Yet the test cases just prove what is so expensive there: name lookups (global name `str`; looking up `join` on a string instance); building a tuple (for function arguments) is expensive as well. Of course `__format__` will be costly as well as it is not a slot-method, needs to build a new string etc. 

However for strings, 'foo'.format() already returns the instance itself, so if you were formatting other strings into strings there are cheap shortcuts available to even overtake 

    a = 'Hello'
    b = 'World'
    '%s %s' % (a, b)

for fast string templates, namely, make FORMAT_VALUE without args return the original if `PyUnicode_CheckExact` and no arguments, don't need to build a tuple to join it.
History
Date User Action Args
2016-07-13 14:44:09ztanesetrecipients: + ztane, mjpieters, eric.smith, serhiy.storchaka, Demur Rumed
2016-07-13 14:44:09ztanesetmessageid: <1468421049.74.0.421102567667.issue27078@psf.upfronthosting.co.za>
2016-07-13 14:44:09ztanelinkissue27078 messages
2016-07-13 14:44:09ztanecreate