8 May
2015
8 May
'15
11:01 p.m.
On Sat, May 9, 2015 at 2:04 PM, Nikolaus Rath
On May 07 2015, Steven D'Aprano
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?
T