[Python-Dev] Slice as a copy... by design?
Scott Dial
scott+python-dev at scottdial.com
Thu May 22 18:22:53 CEST 2008
Facundo Batista wrote:
> I couldn't answer why, so I'm asking here...Is it because the
> reference counting will be complicated? Is it because it'd be
> inefficient in other way? It's something else? Or is something that
> could be done... but is not done yet?
If we changed Python to slice-by-reference, then tomorrow someone would
be asking why it isn't slice-by-copy. There are pros and cons to both
that are dependent on your application. It's not hard to imagine
applications where you want to hold onto a small portion of a large
string, thereby forcing the entire string to remain in memory. If a
slices had a copy method, then I suppose this would be moot.
-Scott
--
Scott Dial
scott at scottdial.com
scodial at cs.indiana.edu
More information about the Python-Dev
mailing list