Disable automatic interning
George Sakkis
george.sakkis at gmail.com
Wed Mar 18 13:54:03 EDT 2009
Is there a way to turn off (either globally or explicitly per
instance) the automatic interning optimization that happens for small
integers and strings (and perhaps other types) ? I tried several
workarounds but nothing worked:
>>> 'x' is 'x'
True
>>> 'x' is 'x'+''
True
>>> 'x' is ''+'x'
True
>>> 'x' is 'x'*1
True
>>> 'x' is str('x')
True
>>> 'x' is str('x')+str('')
True
>>> 'x' is str.__new__(str,'x')
True
George
More information about the Python-list
mailing list