Skip to content

Conversation

@jparisu
Copy link
Contributor

@jparisu jparisu commented Jun 28, 2023

This PR tried to use ctypes library to pass bytes from Python to C++ avoiding a copy in the process.
2 methods were tried:

  1. Adding ctypes to SWIG files so ctypes code was directly inserted in final python library (tested, but not uploaded).
  2. Using a parallel amlip_ctypes package to parse some Classes through ctypes, and the rest using SWIG (this is the code that is uploaded in the current version of the PR).

Conclusions

These tests were unsuccessful due to the connection between ctypes and SWIG.
First of all, ctypes requires C functions, and it does not allow classes, or it is very difficult to work with them.
Secondly, SWIG generates its own C++ classes and the user is not aware of them, neither appear in the final .py library.
Third, SWIG checks the input types of every method, and ctypes relies on using C pointers to pass every type as the same data type.
Due to these reasons, I did not found a way to use ctypes and SWIG in parallel to pass bytes from Python to C++ without copy.

Disclaimer

This PR adds a demo that IS NOT WORKING.

Signed-off-by: jparisu <javierparis@eprosima.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.

2 participants