⬅︎ Back to Case insensitive list remove call
prefer the list comp personally, butfor idx, item in enumerate(list_): if ss(item) == element: del list_[idx] break# is it a bit more efficient in worst case.
See the test cases on http://www.peterbe.com/plog/case-insensitive-list-remove-call-part-ii/iremove.pyand notice how unfortunately few of them are long lists. If they were really really long, a O(log n) method like this might beat the list comprehension one.
Comment
prefer the list comp personally, but
for idx, item in enumerate(list_):
if ss(item) == element:
del list_[idx]
break
# is it a bit more efficient in worst case.
Replies
See the test cases on http://www.peterbe.com/plog/case-insensitive-list-remove-call-part-ii/iremove.py
and notice how unfortunately few of them are long lists. If they were really really long, a O(log n) method like this might beat the list comprehension one.