import dataclasses


def asdict(obj, *, dict_factory=dict) -> dict:
    """Return the fields of a record as a new dictionary.

    The returned dictionary maps field names to field values.

    If given, 'dict_factory' will be used instead of built-in dict.
    The function applies recursively to field values that are
    dataclass instances. This will also look into built-in containers:
    tuples, lists, and dicts.
    """
    return dataclasses.asdict(obj, dict_factory=dict_factory)