I've got the entire contents of a text file (at least a few KB) in string myStr.
Will the following code create a copy of the string (less the first character) in memory?
myStr = myStr[1:]
I'm hoping it just refers to a different location in the same internal buffer. If not, is there a more efficient way to do this?
Thanks!
Note: I'm using Python 2.5.
[s[0:n] for n in range(0, len(s))], you'll end up with O(n^2), where in-place slicing would give you O(n). You can always code around it, obviously; it's just extra work.