@classmethod
def _cast(cls, obj):
    """Cast a ComputedObject to a new instance of the same class as this.

    Args:
      obj: The object to cast.

    Returns:
      The cast object, and instance of the class on which this method is called.
    """
    if isinstance(obj, cls):
        return obj
    else:
        result = cls.__new__(cls)
        result.func = obj.func
        result.args = obj.args
        result.varName = obj.varName
        return result
