def queryset_iterator(queryset, chunksize=1000):
    """
    The queryset iterator helps to keep the memory consumption down.
    And also making it easier to process for weaker computers.
    """

    primary_key = 0
    last_pk = queryset.order_by('-pk')[0].pk
    queryset = queryset.order_by('pk')
    while last_pk < primary_key:
        for row in queryset.filter(pk__gt=primary_key)[:chunksize]:
            primary_key = row.pk
            yield row
        gc.collect()
dataset/ETHPy150Open SmileyChris/easy-thumbnails/easy_thumbnails/management/commands/thumbnail_cleanup.py/queryset_iterator/swapped operands of `<`