[Python-Dev] RE: [Python-checkins] python/nondist/peps pep-0323.txt, NONE, 1.1 pep-0000.txt, 1.254, 1.255

Alex Martelli aleaxit at yahoo.com
Tue Oct 28 04:27:06 EST 2003

On Tuesday 28 October 2003 01:54 am, Guido van Rossum wrote:
> > Also, I have a question about the semantic specification of what a copy
> > is supposed to do.  Does it guarantee that the same data stream will be
> > reproduced?  For instance, would a generator of random words expect its
> > copy to generate the same word sequence.  Or, would a copy of a
> > dictionary iterator change its output if the underlying dictionary got
> > updated (i.e. should the dict be frozen to changes when a copy exists or
> > should it mutate).
> Every attempt should be made for the two copies to return exactly the
> same stream of values.  This is the pure tee() semantics.

Yes, but iterators that run on underlying containers don't guarantee,
in general, what happens if the container is mutated while the iteration
is going on -- arbitrary items may end up being skipped, repeated, etc.
So, "every attempt" is, I feel, too strong here.

deepcopy exists for those cases where one is ready to pay a hefty
price for guarantees of "decoupling", after all.


More information about the Python-Dev mailing list