[Python-Dev] Subtle difference between f-strings and str.format()

Terry Reedy tjreedy at udel.edu
Thu Mar 29 11:06:47 EDT 2018


On 3/28/2018 11:27 AM, Serhiy Storchaka wrote:
> The optimizer already changes 
> semantic. Non-optimized "if a and True:" would call bool(a) twice, but 
> optimized code calls it only once.

Perhaps Ref 3.3.1 object.__bool__ entry, after " should return False or 
True.", should say something like "Should not have side-effects, as 
redundant bool calls may be optimized away (bool(bool(ob)) should have 
the same result as bool(ob))."


-- 
Terry Jan Reedy



More information about the Python-Dev mailing list