deque slicing
Steven Bethard
steven.bethard at gmail.com
Wed Sep 15 02:27:59 EDT 2004
Raymond Hettinger <vze4rx4y <at> verizon.net> writes:
> Even getitem/setitem were a stretch (they perform best at endpoints) and were
> added to make deques substitutable for lists in stack/queue applications
> using d[0] and d[-1] to implement peekleft() and peekright() operations.
Ahh, ok, so the functionality I was really looking for is peekleft(n). That
is, a peek function that would return the first n items, starting at the
left. (If you're curious why I wanted this, see the peekable class in
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/304373.) I assumed
that the best way to get this was slicing, but are there plans for such a
peekleft function?
Steve
More information about the Python-list
mailing list