I was wondering, if there is way in Python to modify collections without creating new ones. E.g.:
lst = [1, 2, 3, 4, 5, 6]
new_lst = [i for i in lst if i > 3]
Works just fine, but a new collection is created. Is there a reason, that Python collections lack a filter()
method (or similar) that would modify the collection object in place?