deque slicing
Steven Bethard
steven.bethard at gmail.com
Tue Sep 14 14:28:00 EDT 2004
Anyone know why deques don't support slicing?
>>> from collections import deque
>>> d = deque(i**2 - i + 1 for i in range(10))
>>> d
deque([1, 1, 3, 7, 13, 21, 31, 43, 57, 73])
>>> d[:5]
Traceback (most recent call last):
File "<stdin>", line 1, in ?
TypeError: sequence index must be integer
>>> [d[i] for i in range(5)]
[1, 1, 3, 7, 13]
Is there a performance problem with supporting slicing perhaps?
Steve
--
You can wordify anything if you just verb it.
- Bucky Katt, Get Fuzzy
More information about the Python-list
mailing list