intern'ed strings and deepcopy()

"Martin v. Löwis" martin at v.loewis.de
Sat Apr 12 04:49:40 EDT 2003


Alexander Schmolck wrote:
> But I'm not sure that that's what the OP's up to. 

The original poster asked (paraphrased)
"Am I right assuming that interned strings are not copied
by deepcopy?"

to which the short answer is

"Yes, you are right"

The slightly longer answer is

"Yes. Strings are never copied by deepcopy since deepcopy
knows they are immutable. Whether they are interned or not
is irrelevant".

When Eric Max said "its identity is unimportant", he really
meant "it's unimportant whether they are interned, and their
identity is preserved in deepcopy" :-)

Regards,
Martin





More information about the Python-list mailing list