3 ms·
#Takes around 1 second s="a"*3000000000 #instant, does not consume twice as much memory. s+="a" I don't know the internals, but certainly there's not a new st
by TZubiri 1y ago
#Takes around 1 second
s="a"*3000000000
#instant, does not consume twice as much memory.
s+="a"
I don't know the internals, but certainly there's not a new string being created. Maybe if it exceeds capacity? Who cares at that point, it's python strings, not Matmuls in C.