On 2020-01-22 01:52, Ethan Furman wrote:
On 01/21/2020 10:55 AM, Michael Torrie wrote:
Slicing
returns a new object whether one is slicing a tuple, list, or a string,
the latter two are mutable objects.
Strings are not mutable.
In the case of tuples and strings, if the slicing encompasses the entire
object, the original object is returned:
>>> t = (0, 1, 2)
>>> t[:] is t
True
>>> s = "012"
>>> s[:] is s
True
Those are safe optimisations because they are immutable objects.
--
https://mail.python.org/mailman/listinfo/python-list