FYI. 5000 iterations of both matching and unmatching versions of a test on different sizes of the input list.
List Size 10
0.00530 aList.count(aList[0] ) == len(aList)
0.00699 for with return False if no match found.
0.00892 aList == [aList[0]] * len(aList)
0.00974 len(set(aList)) == 1
0.02334 all(aList[0] == x for x in aList)
0.02693 reduce(lambda x,y:x==y and x,aList)
List Size 100
0.01547 aList.count(aList[0] ) == len(aList)
0.01623 aList == [aList[0]] * len(aList)
0.03525 for with return False if no match found.
0.05122 len(set(aList)) == 1
0.08079 all(aList[0] == x for x in aList)
0.22797 reduce(lambda x,y:x==y and x,aList)
List Size 1000
0.09198 aList == [aList[0]] * len(aList)
0.11862 aList.count(aList[0] ) == len(aList)
0.31874 for with return False if no match found.
0.36145 len(set(aList)) == 1
0.65861 all(aList[0] == x for x in aList)
2.24386 reduce(lambda x,y:x==y and x,aList)
Clear winners and losers. count rules.
Here's the quickExit version that runs pretty quickly, but isn't a one-liner.
def quickExit( aList ):
"""for with return False if no match found."""
value= aList[0]
for x in aList:
if x != value: return False
return True