def convert(data):
    if isinstance(data, bytes):
        return data.decode()
if isinstance(data, (str, int)):
    return str(data)
if isinstance(data, dict):
    return dict(map(convert, list(data.items())))
if isinstance(data, tuple):
    return tuple(map(convert, data))
if isinstance(data, list):
    return list(map(convert, data))
if isinstance(data, set):
    return set(map(convert, data))
Fastest way to convert a dict's keys & values from `bytes` to `str` in python3