def fill_interval(filename, endpoints, size_of_chunk=64*1024):
    '''return count of values before interval, interval, data len'''
    with open(filename, 'rb') as input_file:
        first_endpoint = endpoints[0]
        last_endpoint = endpoints[1]
        seek_position = 0
        interval = array('f')
        iappend = interval.append
        pre_count = 0
        count = 0
        input_file.seek(seek_position)
        buf_str = input_file.read(size_of_chunk)
        while buf_str:
            last_endl = buf_str.rfind('\n')
            buf_arr = array('f', map(float,
                                     buf_str[:(last_endl+1)].splitlines()))
            count = count + len(buf_arr)
            for value in buf_arr:
                if value <= first_endpoint:
                    pre_count = pre_count + 1
                elif last_endpoint <= value:
                    pass
                else:
                    iappend(value)
            seek_position = seek_position + (last_endl+1)
            input_file.seek(seek_position)
            buf_str = input_file.read(size_of_chunk)

    return interval, count, pre_count
return count of values before interval, interval, data len
recipes/Python/577478_Search_nth_smallest_element_really_big/recipe-577478.py