[Python-Dev] re: Tutorial: Brief Introduction to the Standard Libary (original) (raw)

Greg Ewing greg at cosc.canterbury.ac.nz
Wed Dec 3 22:16:25 EST 2003


Arthur <ajsiegel at optonline.net>:

In my view, there are usually more convenient ways to accomplish what copy is about, because you don't have to import copy. And we are just in a circular argument. And its use is discouraged, as a matter of style. More circles. But isn't it a harmless alternative, and a bit more explicit, in a good deal of circumstances - arguably.

There isn't any "good deal of circumstances" in the first place. I'm not sure why it is, but in my experience, and in other people's too, it seems, it's very rare that you ever need to copy anything in Python. There's nothing circular here -- it would still be true even if copy() were a built-in.

And on the rare occasions where you do need to copy something, you need to know a fair bit about the kind of thing you're copying, and for what purpose you're copying it, so that you know exactly how much of it to copy. It's a delicate operation that I'd be reluctant to trust to any general-purpose copying function.

The result of all this is that I don't think I've ever used copy() or deepcopy(). Whenever I've need to copy something I've always used something type-specific such as list[:] or dict.copy(), or written my own copying function.

Greg Ewing, Computer Science Dept, +--------------------------------------+ University of Canterbury, | A citizen of NewZealandCorp, a | Christchurch, New Zealand | wholly-owned subsidiary of USA Inc. | greg at cosc.canterbury.ac.nz +--------------------------------------+



More information about the Python-Dev mailing list