What are the best ways to compare the contents of two list-like objects?
idioms, polymorphism, python
Solution
Compare it elementwise:
def compare(a,b):
if len(a) != len(b):
return False
return all(i == j for i,j in itertools.izip(a,b))
For Python 3.x, use `zip` instead
Problem
When I have to compare the contents of two array-like objects -- for instance `list`s, `tuple`s or `collection.deque`s -- without regard for the type of the objects, I use ``` list(an_arrayish) == list(another_arrayish) ``` Is there any more idiomatic/faster/better way to achieve this?