Execution speed question

Vlastimil Brom vlastimil.brom at gmail.com
Fri Jul 25 18:01:07 CEST 2008


2008/7/25 Suresh Pillai <stochashtic at yahoo.ca>:

> ...



> I naturally started coding with (2), but couldn't decide on the best data
> structure for python.  A set seemed ideal for speedy removal, but then I
> can't iterate through them with out popping.  An ordered list?  Some
> creative solution with numpy arrays?
>
> ...

Maybe I am missing something, but I'm not sure, where is the problem with
non-destructive iterating over a set, e.g.:
>>> my_set = set([1,2,3,4,5])
>>> my_set
set([1, 2, 3, 4, 5])
>>> for item in my_set: print item,
...
1 2 3 4 5
>>> my_set
set([1, 2, 3, 4, 5])
>>> my_set -= set([2,4])
>>> my_set
set([1, 3, 5])
>>>
Of course, the suitability for your application would depend on other
factors too.
vbr
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20080725/795fb6f9/attachment.html>


More information about the Python-list mailing list