[Python-Dev] decimal.Context.copy() shallow or deep?

Raymond Hettinger raymond.hettinger at verizon.net
Sat Aug 7 16:45:47 CEST 2004


Currently, the copy() method for Context objects makes a shallow copy of
the context.  To get a deepcopy, you have to use
copy.deepcopy(thecontext).

Though, copies are usually shallow and deepcopies are deep, I'm now
having misgivings about the copy method.  I would think that a deep copy
is almost invariably what you would want and expect, (i.e. the copy
doesn't share traps and flags with the original).

Do you guys think it should be left alone (shallow) or changed (made
deep)?

The wrinkle in all this is that internally the module makes many uses of
copy and expects it to be shallow (or least, tests fail in droves when
copy is made deep).  So I would have to rename the current copy to
_shallow_copy and replace the original with a deep version for the
public API.

Any thoughts?


Raymond



More information about the Python-Dev mailing list