Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/pybag/translate.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,10 @@ def _translate_value_ros1_to_ros2(value: Any) -> Any:

# Handle lists/arrays
if isinstance(value, list):
# Fast path: empty lists or primitive arrays (int, float, str, bool, bytes)
# These cannot contain Time/Duration objects, so skip recursion
if not value or isinstance(value[0], (int, float, str, bool, bytes)):
return value.copy()
return [_translate_value_ros1_to_ros2(item) for item in value]

# Handle dataclass (nested message)
Expand Down Expand Up @@ -178,6 +182,10 @@ def _translate_value_ros2_to_ros1(value: Any) -> Any:

# Handle lists/arrays
if isinstance(value, list):
# Fast path: empty lists or primitive arrays (int, float, str, bool, bytes)
# These cannot contain Time/Duration objects, so skip recursion
if not value or isinstance(value[0], (int, float, str, bool, bytes)):
return value.copy()
return [_translate_value_ros2_to_ros1(item) for item in value]

# Handle dataclass (nested message)
Expand Down