gsakkis at rutgers.edu
Mon Jan 24 17:42:55 EST 2005
"Peter Hansen" <peter at engcorp.com> wrote in message news:A9OdnRotCdqJ-2jcRVn-jA at powergate.ca...
> George Sakkis wrote:
> > Fair enough. So perhaps the question is whether such cases are more regular than something like:
> > a = give_me_a_huge_tuple()
> > slices = [a[i:j] for i in xrange(len(a)) for j in xrange(i+1, len(a)+1)]
> I believe the general usage of tuples tends to mean that
> "give_me_a_huge_tuple()" just doesn't happen except with
> those who insist on using tuples as though they were nothing
> other than read-only lists.
> If you use a tuple the way it was apparently intended, you
> are extraordinarily unlikely to find yourself with a
> huge one requiring slicing in such a way that you care
> whether it is a "view" or a new object.
Actually my initial motivation was not a huge tuple I had to slice many times. It was something much
less extraordinarily unlikely, a recursive function with a sequence parameter:
Having each slice be a view of the original sequence instead of a fresh copy would be a Good Thing
More information about the Python-list