[Python-ideas] Why don't CPython strings implement slicing using a view?
Mark Lawrence
breamoreboy at yahoo.co.uk
Sat May 9 10:51:18 CEST 2015
More information about the Python-ideas mailing list
Sat May 9 10:51:18 CEST 2015
- Previous message (by thread): [Python-ideas] Why don't CPython strings implement slicing using a view?
- Next message (by thread): [Python-ideas] Why don't CPython strings implement slicing using a view?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 09/05/2015 08:31, Andrew Barnert via Python-ideas wrote: > On May 8, 2015, at 21:04, Nikolaus Rath <Nikolaus at rath.org> wrote: >> >>> On May 07 2015, Steven D'Aprano <steve-iDnA/YwAAsAk+I/owrrOrA at 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? > > Of course I could be wrong; we won't really know until someone actually builds at least an implementation and tests it. Well they can, but I found a major problem with views is that you can't compare them and so can't sort them, thus rendering them useless for a lot of applications. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence
- Previous message (by thread): [Python-ideas] Why don't CPython strings implement slicing using a view?
- Next message (by thread): [Python-ideas] Why don't CPython strings implement slicing using a view?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-ideas mailing list