Skip to content
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

memoryview / buffer inputs should be accepted as serializable data #107

Open
tzickel opened this issue Aug 28, 2019 · 1 comment · May be fixed by #108 or #147
Open

memoryview / buffer inputs should be accepted as serializable data #107

tzickel opened this issue Aug 28, 2019 · 1 comment · May be fixed by #108 or #147

Comments

@tzickel
Copy link

tzickel commented Aug 28, 2019

Let's say I have a large numpy array that represents an std_msgs/Image.data

Today if I try to publish such a message it will fail in this part of the serialize function:

      if type(_x) in [list, tuple]:
        buff.write(struct.pack('<I%sB'%length, length, *_x))
      else:
        buff.write(struct.pack('<I%ss'%length, length, _x))

So I would have to to .tostring() or something which will do a copy (and then another copy in struct.pack).

I think that a check should be added if it's a memoryview (py3) or buffer (py2), and then only struct.pack the length, and then simply buff.write the object itself directly.

@dirk-thomas
Copy link
Member

Please consider to contribute a pull request implementing this feature idea. Please also cover the new functionality with unit tests if you do.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants