On Sat, May 9, 2015 at 2:04 PM, Nikolaus Rath Nikolaus@rath.org wrote:
On May 07 2015, Steven D'Aprano steve-iDnA/YwAAsAk+I/owrrOrA@public.gmane.org wrote:
But a view would be harmful in this situation:
s = "some string"*1000000 t = s[1:2] # a view maskerading as a new string del s
Now we keep the entire string alive long after it is needed.
How would you solve the first problem without introducing the second?
Keep track of the reference count of the underlying string, and if it goes down to one, turn the view into a copy and remove the sliced original?