which is better, string concatentation or substitution?

Casey Hawthorne caseyhHAMMER_TIME at istar.ca
Mon May 8 22:32:21 EDT 2006


roy at panix.com (Roy Smith) wrote:

>O(n^0), which is almost always written as O(1).  This is a "constant
>time" algorithm, one which takes the same amount of steps to execute
>no matter how big the input is.  For example, in python, you can
>write, "x = 'foo'".  That assignment statement takes the same amount
>of time no matter how long the string is.  All of these execute in the
>same number of steps:
>
>	x = ''
>	x = 'foo'
>	x = 'a very long string with lots and lots of characters'
>
>We can say that "assignment is constant time", or "assignment is
>O(1)".

Constant time if converted to byte code or compiled?

O(n) in string length if being interpreted?
--
Regards,
Casey



More information about the Python-list mailing list