genpy icon indicating copy to clipboard operation
genpy copied to clipboard

Use numpy.array's "offset" param instead of slicing

Open abencz opened this issue 11 years ago • 4 comments

Passing an offset into numpy.array instead of slicing should prevent an additional copy of the data being created by the slice operation. This is important for really big message types like OccupancyGrids.

Documentation of the offset parameter: http://docs.scipy.org/doc/numpy/reference/generated/numpy.frombuffer.html

abencz avatar Nov 26 '14 14:11 abencz

@dirk-thomas, any thoughts on this?

mikepurvis avatar Nov 28 '14 20:11 mikepurvis

It would be great to improve the performance of this by avoiding the extra copy.

The current patch breaks the public API (introducing the offset argument in the middle of other positional arguments). Can you please change that to something non-breaking, e.g. an optional keyword argument?

I haven't checked how well this code path is covered by a unit test. If not could you please also add a unit test to ensure the new feature doesn't break in the future?

dirk-thomas avatar Dec 01 '14 18:12 dirk-thomas

If anyone is interested enough in this feature to update the PR with the above comments that would be highly appreciated?

dirk-thomas avatar Mar 20 '15 18:03 dirk-thomas

I wasn't aware that genpy, and especially unpack_numpy was part of the public API of ROS. I'll update the PR.

abencz avatar Feb 03 '16 21:02 abencz