from datetime import datetime


def datetime_to_fractional_year(input: datetime) -> float:
    """Converts a Python datetime object to a fractional year."""
    start = date(input.year, 1, 1).toordinal()  # type: ignore
    year_length = date(input.year + 1, 1, 1).toordinal() - start  # type: ignore
    return input.year + (input.toordinal() - start) / year_length