def is_sublist(needle, haystack):
    """True if needle is a sublist of haystack, False otherwise.
    Could be more efficient with Boyer-Moore-Horspool but our needles
    are usually ngrams (ie. short), so this is a O(nm) implementation.
    """
    ln = len(needle)
    lh = len(haystack)
    for pos in range(lh - ln + 1):
        if needle == haystack[pos:pos+ln]:
            return True
    return False