mirror of https://github.com/commaai/openpilot.git
can do this if we're desperate for the last few %
This commit is contained in:
parent
a5e363d8db
commit
18e11ac788
|
@ -80,10 +80,14 @@ def asdictref(obj) -> dict[str, Any]:
|
|||
for field in getattr(obj, _FIELDS): # similar to dataclasses.fields()
|
||||
ret[field] = _asdictref_inner(getattr(obj, field))
|
||||
return ret
|
||||
elif isinstance(obj, (tuple, list)):
|
||||
return type(obj)(_asdictref_inner(v) for v in obj)
|
||||
else:
|
||||
return obj
|
||||
obj_type = type(obj)
|
||||
if obj_type is list:
|
||||
return [_asdictref_inner(v) for v in obj]
|
||||
elif obj_type is tuple:
|
||||
return tuple(_asdictref_inner(v) for v in obj)
|
||||
else:
|
||||
return obj
|
||||
|
||||
return _asdictref_inner(obj)
|
||||
|
||||
|
|
Loading…
Reference in New Issue