-
Notifications
You must be signed in to change notification settings - Fork 108
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Inconsistent typecast in Python with PointCloud2 #176
Comments
Relevant PR where this issue has been discovered #175. |
This was referenced Mar 13, 2022
Closed in favor of ros2/rosidl_python#155 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The behavior differs depending on the datatype and whether it is set via the constructor or the class constructor when generating a PointCloud2 Message in Python.
If set via the constructor, the cast is directly performed. If the data property is used instead, a check if performed whether the data already has the appropriate datatype. In addition to that, the constructor uses the property setter method, so it can just be passed through to the setter without a cast in the constructor.
Bug report
Required Info:
Steps to reproduce issue
array.array
to the PointCloud2 constructor in pythonmsg.data = yourarray
The second one is much faster, as the setter for the property skips the conversion.
Implementation 1: 2.714930295944214 seconds # constructor
Implementation 2: 1.379800796508789 seconds # property
Expected behavior
Both should be equally fast
Actual behavior
The second one is much faster, because the array is not casted twice.
The constructor calls the setter (redundantly) with
The setter itself checks if the cast is already done
Additional information
Implementation considerations
Just use
I honestly don't know how to change this since the code seems to be auto generated. In this case it would be even worse as the issue is not only happening for the PointCloud2.
The text was updated successfully, but these errors were encountered: