How efficient is Python substring extraction?

Posted by Cameron on Stack Overflow See other posts from Stack Overflow or by Cameron
Published on 2010-03-16T19:16:59Z Indexed on 2010/03/16 19:51 UTC
Read the original article Hit count: 389

Filed under:
|
|
|

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.

© Stack Overflow or respective owner

Related posts about python

Related posts about substring