def datetime_tuple_to_long(year: int, month: int, day: int, hour: int,
    minute: int, second: int, msecond: int=0) ->int:
    """ self contained to avoid function calling overhead """
    mth: int = (month + 9) % 12
    yr: int = year - mth // 10
    date_int: int = 365 * yr + yr // 4 - yr // 100 + yr // 400 + (mth * 306 + 5
        ) // 10 + (day - 1)
    time_int: int = (hour * 3600 * 1000 + minute * 60 * 1000 + second * 
        1000 + msecond // 1000)
    return (date_int << 32) + time_int
