[Python-Dev] set.copy documentation string

Noam Raphael noamraph at gmail.com
Thu Dec 29 00:31:44 CET 2005


On 12/29/05, "Martin v. Löwis" <martin at v.loewis.de> wrote:
> Noam Raphael wrote:
> > is currently "Return a shallow copy of a set."
> >
> > Perhaps "shallow" should be removed, since set members are supposed to
> > be immutable so there's no point in a deep copy?
>
> That still doesn't make copy return a deep copy, right? "shallow copy"
> is more precise than "copy", and correct - what is gained from
> removing it?

Perhaps it bothers the programmer with something that shouldn't bother
him. I mean that I might do help(set.copy), and then think, "Oh, it
returns a shallow copy. Wait a minute - 'shallow' means that I get a
new object, which references the same objects as the old one. Perhaps
I should use another function, which does deep copying? Let me think
about it - no. All members of a set are immutable, so it doesn't
matter." I think that in this case, the fact that the copy is shallow
is an implementation detail, since there's no sense in making a deep
copy of a set. Implementation details should probably not be a part of
the definition of what a method does.

I know it's just a word, and that it doesn't matter a lot. But why not
make things a tiny bit better?

Noam


More information about the Python-Dev mailing list