[Python-3000] Making more effective use of slice objects in Py3k

Greg Ewing greg.ewing at canterbury.ac.nz
Thu Aug 31 01:59:07 CEST 2006


Josiah Carlson wrote:

> Up until this morning I was planning on writing everything such that
> constructive manipulation (upper(), __add__, etc.) returned views of
> strings.

I was about to say that this would be completely pointless,
when I realised the point is so that further operations on
these results would return views of them. In Josiah's
views-always-return-views world, that would actually make
sense -- but only if we really wanted such a world.

To my mind, the use of views is to temporarily call out
a part of a string for the purpose of applying some
other operation to it. Views will therefore be
short-lived objects that you won't want to keep and
pass around. I suspect that, if views are the default
result of anything done to a view, one will almost
always be doing a str() on the result to turn it back
into a non-view. If that's the case, then returning
views would be the wrong default.

--
Greg


More information about the Python-3000 mailing list