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

[NOT MERGE] Implementation using ctypes (not working) #85

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

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.

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.

1 participant