intern'ed strings and deepcopy()

Alexander Schmolck a.schmolck at
Sun Apr 13 19:00:27 CEST 2003

"Martin v. Löwis" <martin at> writes:

> 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" :-)

Ah, I see, thanks for clearing this up :)


More information about the Python-list mailing list