2

Is there any way to use cffi to extract the contents of a capsule and convert it into a voidptr which I can send into C code?

Background info -- numpy arrays can give you a capsule containing a very handy struct, namely the PyArrayInterface. I don't think capsules exist for PyPy yet, so the answer is probably no, but I believe that the future contains capsules for all python versions, so I'm hoping the answer is yes :).

1 Answer 1

1

I don't think so. Capsules are a way for some CPython C extension modules to pass around pointers; typically, between two different C extension modules. If you replace one of these modules with a CFFI version, you loose: there is no official way to get the "void *" value from Python, with or without CFFI. It looks like it would be a valid enhancement. Feel free to open a feature request here:

https://bitbucket.org/cffi/cffi/issues?status=new&status=open

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.