In article <[EMAIL PROTECTED]>, Casey Hawthorne <[EMAIL PROTECTED]> wrote:
> [EMAIL PROTECTED] (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? Compiled, byte-code, or interpreted has nothing to do with it. Assignment would be O(n) if it involved copying the string (as it might in C++ using std:string, for example), but in Python, assignnment simply involves binding a new name to an existing object. -- http://mail.python.org/mailman/listinfo/python-list