[Python-Dev] Slice as a copy... by design? (original) (raw)

Facundo Batista facundobatista at gmail.com
Thu May 22 18:24:06 CEST 2008


2008/5/22 Oleg Broytmann <phd at phd.pp.ru>:

I remember some discussions... let me see... google to help... aha:

http://mail.python.org/pipermail/python-3000/2006-August/003224.html http://mail.python.org/pipermail/python-3000/2006-August/003242.html

These descussions are too general, and implies some work regarding the unification between slice and range, and discusses sequences in general... I'm just asking about strings (the discussion could apply similarly to bytes, but not bytearrays), and why slicing them returns a copy.

Of course that when the slice has the step component different that 1, or reverses the string, this could not be done. But when the slice is mystring[x:y], being x < y, we could return just a view of the string (llot of emphasis to that "could").

Thanks.

-- . Facundo

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



More information about the Python-Dev mailing list