def all_same(items):
    'Quick check if all items are the same.\n\n    Identical to a check like len(set(items)) == 1 but\n    should be more efficient while working on generators, since would\n    return False as soon as any difference detected thus possibly avoiding\n    unnecessary evaluations\n    '
    first = True
    first_item = None
    for item in items:
        if first:
            first = False
            first_item = item
        elif (item != first_item):
            return False
    return (not first)
Quick check if all items are the same.

Identical to a check like len(set(items)) == 1 but
should be more efficient while working on generators, since would
return False as soon as any difference detected thus possibly avoiding
unnecessary evaluations
def all_same(items):
    'Quick check if all items are the same.\n\n    Identical to a check like len(set(items)) == 1 but\n    should be more efficient while working on generators, since would\n    return False as soon as any difference detected thus possibly avoiding\n    unnecessary evaluations\n    '
    first = True
    first_item = None
    for item in items:
        if first:
            first = False
            first_item = item
        elif (item != first_item):
            return False
    return (not first)