Skip to content

Skip redundant checks when assigning bytes to uint8[] fields - #273

Open
Nishant-ZFYII wants to merge 1 commit into
ros2:rollingfrom
Nishant-ZFYII:fast-path-bytes-uint8-sequence
Open

Nishant-ZFYII wants to merge 1 commit into
ros2:rollingfrom
Nishant-ZFYII:fast-path-bytes-uint8-sequence

Conversation

@Nishant-ZFYII

Copy link
Copy Markdown

Every element of a bytes or bytearray is already an int in 0-255, so the per-element field checks can never fail. They just loop over the whole payload, which takes ~180 ms for a 6 MB PointCloud2 when ROS_PYTHON_CHECK_FIELDS=1. Convert it straight to array.array('B') instead. Behaviour is unchanged.

Fixes #156.

Description

Fixes # (issue)

Is this user-facing behavior change?

Did you use Generative AI?

Additional Information

Every element of a bytes or bytearray is already an int in 0-255, so the per-element field checks can never fail. They just loop over the whole payload, which takes ~180 ms for a 6 MB PointCloud2 when ROS_PYTHON_CHECK_FIELDS=1. Convert it straight to array.array('B') instead. Behaviour is unchanged.

Fixes ros2#156.

Signed-off-by: Nishant-ZFYII <nishantpushparaju@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Extremely slow message creation for large arrays in Python

1 participant