code: def object_to_bytes(obj):
      
      if isinstance(obj, str):
          return bytearray(obj, "UTF-8")
      elif isinstance(obj, bool):
          return bytearray()
      elif isinstance(obj, int):
          return pack("<L", obj)
      elif obj is None:
          return bytearray()
      elif isinstance(obj, bytearray):
          return obj
      else:
          return obj.get_raw()
docs: Convert a object to a bytearray or call get_raw() of the object
      if no useful type was found.