intern'ed strings and deepcopy()

Alexander Schmolck a.schmolck at gmx.net
Sat Apr 12 02:49:15 CEST 2003


Erik Max Francis <max at alcyone.com> writes:

> My point was that if you find yourself wanting to make a truly unique
> copy of a string (an immutable object), then there is almost certainly
> something wrong with your design.

Hmm, do you mean if you want ``x is not y`` but ``x == y`` for interned string
x and some string y?

But I'm not sure that that's what the OP's up to. E.g. you could have a
container mapping symbols to other things -- possibly also symbols or further
containers. You then might want to make a deepcopy of it. You presumably still
want the symbols to be the same symbols in the copy (so that you can make use
of the identity), so asking whether ``deepcopy(symbol) is symbol`` doesn't
seem that unreasonable to me (is it?).

'as




More information about the Python-list mailing list