> - use arrays for each 'section' rather than content += . This allows better > separation of the sections and also will perform better as long strings > with += are slow.
+1 for better separation. I don't think there is significant difference: For an 100-line eni (that's rather high for typical usage) % python3 t.py Concat: 7.116918564017396 Array : 7.6817819369607605 % python2 t.py Generating data... Concat: 8.51635122299 Array : 7.93058490753 For a 10-line eni % python3 t.py Generating data... Concat: 1.0464658139972016 Array : 1.2140009650029242 % python2 t.py Generating data... Concat: 0.956037998199 Array : 1.08836984634 % cat t.py import timeit concat = """ c='' for x in range(0, 100): c += 'iface eth0 inet static' """ append = """ c = [] for x in range(0, 100): c.append('iface eth0 inet static') """ print('Generating data...') print("Concat: %s" % timeit.timeit(concat)) print("Array : %s" % timeit.timeit(append)) -- https://code.launchpad.net/~smoser/cloud-init/trunk.net-improve-lo-dns/+merge/298035 Your team cloud init development team is requested to review the proposed merge of lp:~smoser/cloud-init/trunk.net-improve-lo-dns into lp:cloud-init. _______________________________________________ Mailing list: https://launchpad.net/~cloud-init-dev Post to : cloud-init-dev@lists.launchpad.net Unsubscribe : https://launchpad.net/~cloud-init-dev More help : https://help.launchpad.net/ListHelp