I'm interested in how is Python handling slicing where the stop attribute is larger than the length of the string we are working with, for example:
my_string = 'abc'
my_slice = my_string[:10]
I am aware that my_slice == 'abc'
, what interests me is how efficient this is and how it works under the hood.
I've read Time complexity of string slice and Understanding slice notation, but didn't find the exact case I was looking for.
My guess based on mentioned sources would be that a shallow copy of the string is returned (my_string[:10]
is the same as my_string[:]
in this case), is this the case?