[Python-Dev] Slice as a copy... by design?

Facundo Batista facundobatista at gmail.com
Thu May 22 18:27:04 CEST 2008


2008/5/22 Scott Dial <scott+python-dev at scottdial.com>:

> 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

Which are the cons of slice-by-reference of an immutable string?


> 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

This is a garbage collection issue. It's real, and maybe could be
optimized somehow... but I think that this un-optimization is by far
smaller than the optimization of not copying it in the first place.

-- 
. Facundo

Blog: http://www.taniquetil.com.ar/plog/
PyAr: http://www.python.org/ar/


More information about the Python-Dev mailing list