Is empty string cached?

Farshid Lashkari flashkNO at SPAMgmail.com
Wed Feb 15 22:50:04 EST 2006


> I really don't understand why it's so important: it's not a part of the 
> language definition at all, and therefore whatever behavior you see is 
> simply an artifact of the implementation you observe.

I guess I should rephrase my question in the form of an example. Should 
I assume that a new string object is created in each iteration of the 
following loop?

for x in xrange(1000000):
     func(x,'some string')

Or would it be better to do the following?

stringVal = 'some string'
for x in xrange(1000000):
     func(x,stringVal)

Or, like you stated, is it not important at all?

Thanks,
Farshid



More information about the Python-list mailing list