cirq.obj_to_dict_helper(obj: Any, attribute_names: Iterable[str], namespace: Optional[str] = None) → Dict[str, Any][source]

Construct a dictionary containing attributes from obj

This is useful as a helper function in objects implementing the
SupportsJSON protocol, particularly in the json_dict method.
In addition to keys and values specified by attribute_names, the
returned dictionary has an additional key “cirq_type” whose value
is the string name of the type of obj.
  • obj – A python object with attributes to be placed in the dictionary.

  • attribute_names – The names of attributes to serve as keys in the resultant dictionary. The values will be the attribute values.

  • namespace – An optional prefix to the value associated with the key “cirq_type”. The namespace name will be joined with the class name via a dot (.)