Use cases for del

Terry Reedy tjreedy at
Sun Jul 10 22:14:44 CEST 2005

"Ron Adam" <rrr at> wrote in message 
news:OI_ze.189063$IO.87173 at
> To avoid that you either need to define the flag string as a global name
> or use it strictly in the local scope it's defined in.  Python will also
> sometimes reuse strings as an optimization instead of creating a second
> string if they are equal.  Something else to be aware of.

I believe CPython's string equality function first checks the two strings 
for identity.  So one gets most of the benefit of 'is' testing anyway.  (An 
I presume it next check for length equality.)


More information about the Python-list mailing list