George Sakkis wrote:
You're probably right about the allocation time, but my main concern is the 
memory required for each
slice, which can be O(n) wrt the length of the whole tuple. I would like this 
to be constant (at
least if there was a way around to the problem of deleting the underlying 
sequence).

If you really want a view into a tuple (or any sequence for that matter):

  from itertools import islice
  islice(iter(seq), start, end, step)

Then use the various functions in itertools to work with the resulting iterator (since the syntactic support for working with iterators is currently quite limited - slicing, concatenation and repetition are spelt with itertools.islice(), itertools.chain() and itertools.repeat(), rather than with their standard syntactic equivalents "[x:y:z]", "+" and "*").

The above approach does suffer from the problem of holding a reference to the original sequence, though.

Cheers,
Nick.

--
Nick Coghlan   |   [EMAIL PROTECTED]   |   Brisbane, Australia
---------------------------------------------------------------
            http://boredomandlaziness.skystorm.net
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to