Discussion:
[C++-sig] Returning C++ buffer to Python 2.7
Tony Cappellini
2015-10-15 20:27:29 UTC
Permalink
I've allocated memory in C++ and need to expose a function to Python
so that Python can read this memory as a sequence.


I've found this example

http://pastebin.com/YGi61R4H

from this URL
http://stackoverflow.com/questions/16232520/how-to-expose-raw-byte-buffers-with-boostpython

which **looks** like it will do what I need, from the description of the
code and the request from the original author.

However, it looks incomplete to me. There is no code which defines, or
explains what
*handle<>* is/does, in this line of code

object retval = object(handle<>(py_buf));

I would appreciate some help trying to accomplish this (my statement in the
first line of this message). Useful (working) examples of Boost-to-Python
code are not easily found outside of Stackoverflow.

Thanks

Tony
Tony Cappellini
2015-10-19 17:11:54 UTC
Permalink
See
http://www.boost.org/doc/libs/1_55_0/libs/python/doc/tutorial/doc/html/python/object.html#python.creating_python_objectfor
explanation of handle<>
Thank You!

Loading...