Re: Time Complexity of String Operations

2008-07-22 Thread youtoo
On 22 jul, 01:39, "David Wahler" <[EMAIL PROTECTED]> wrote: > On Mon, Jul 21, 2008 at 10:31 PM, youtoo <[EMAIL PROTECTED]> wrote: > > It has been extensively discussed the time complexity (quadratic) of > > string concatenation (due to string's immutability). > > Actually, it is roughly linear, at

Re: Time Complexity of String Operations

2008-07-21 Thread Terry Reedy
youtoo wrote: It has been extensively discussed the time complexity (quadratic) of string concatenation (due to string's immutability). But what is: == the time complexity of string indexing? Is it constant? == the time complexity of string slicing? Is it O(K) with K the slice's length? How a

Re: Time Complexity of String Operations

2008-07-21 Thread David Wahler
On Mon, Jul 21, 2008 at 10:31 PM, youtoo <[EMAIL PROTECTED]> wrote: > It has been extensively discussed the time complexity (quadratic) of > string concatenation (due to string's immutability). Actually, it is roughly linear, at least for reasonable string lengths: $ python -V Python 2.5.2 $ pyth

Time Complexity of String Operations

2008-07-21 Thread youtoo
It has been extensively discussed the time complexity (quadratic) of string concatenation (due to string's immutability). But what is: == the time complexity of string indexing? Is it constant? == the time complexity of string slicing? Is it O(K) with K the slice's length? How are strings stored