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

Raymond Hettinger python at rcn.com
Sat Aug 7 17:24:03 CEST 2004


> > Do you guys think it should be left alone (shallow) or changed (made
> > deep)?
> 
> A user-visible copy certainly should not share mutable state with the
> original. 

I was afraid of that.  What a PITA.


> It's possible that really argues for a simpler internal
> representation of such state, though.

No doubt that would be the right thing to do (doubly so because that is
how you would do it in C).  Unfortunately, there a ton of code that has
to change to get to an integer and bitmask approach.  Also, you have to
expose constants for masking.  Then, you still have to deal with the
underlying code liking the shallow copies.


> > 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?
> 
> Whatever works <wink>.


Done fast, right, and cheap -- pick any two.


Raymond



More information about the Python-Dev mailing list