def encode_helper(obj, to_builtin):
    """Encode an object into a two element dict using a function
    that can convert it to a builtin data type.
    """
    return dict(__class_name__=str(obj.__class__), __dumped_obj__=
        to_builtin(obj))
