import time
lst = ["Вася", "1"]
def concat(n):
start = time.time()
s = ""
for i in range(n):
s += "Вася" + "1"
end = time.time()
print("%d strings concatenated in %.3f seconds" % (n, end - start))
def join(n):
start = time.time()
for i in range(n):
s = "".join(lst)
end = time.time()
print("%d strings joined in %.3f seconds" % (n, end - start))
concat(3000000)
join(3000000)
aW1wb3J0IHRpbWUKbHN0ID0gWyLQktCw0YHRjyIsICIxIl0JCgoKZGVmIGNvbmNhdChuKToKCXN0YXJ0ID0gdGltZS50aW1lKCkKCXMgPSAiIgoJZm9yIGkgaW4gcmFuZ2Uobik6CgkJcyArPSAi0JLQsNGB0Y8iICsgIjEiCgllbmQgPSB0aW1lLnRpbWUoKQoJcHJpbnQoIiVkIHN0cmluZ3MgY29uY2F0ZW5hdGVkIGluICUuM2Ygc2Vjb25kcyIgJSAobiwgZW5kIC0gc3RhcnQpKQoKCmRlZiBqb2luKG4pOgoJc3RhcnQgPSB0aW1lLnRpbWUoKQoJZm9yIGkgaW4gcmFuZ2Uobik6CgkJcyA9ICIiLmpvaW4obHN0KQoJZW5kID0gdGltZS50aW1lKCkKCXByaW50KCIlZCBzdHJpbmdzIGpvaW5lZCBpbiAlLjNmIHNlY29uZHMiICUgKG4sIGVuZCAtIHN0YXJ0KSkKCgoKY29uY2F0KDMwMDAwMDApCmpvaW4oMzAwMDAwMCk=