from_python non-compiletime-constant
I need to register a from_python conversion where the type object is not a compile constant. I'm trying to write c++ code that will accept a numpy array. AFAICT, the PyTypeObject addresses aren't known at compile time, so can't be used in lvalue_from_pytype template arguments. These pointers can be found at runtime. How do I handle this?
Neal Becker <ndbecker2@gmail.com> writes:
I need to register a from_python conversion where the type object is not a compile constant. I'm trying to write c++ code that will accept a numpy array.
AFAICT, the PyTypeObject addresses aren't known at compile time, so can't be used in lvalue_from_pytype template arguments. These pointers can be found at runtime. How do I handle this?
Just take apart the implementation of lvalue_from_pytype and you'll find lower-level facilities in use that will let you build a similar converter. Unfortunately the code for lvalue_from_pytype is pretty convoluted but I've posted the solution several times before on this list so you should be able to find it. -- Dave Abrahams Boost Consulting www.boost-consulting.com
participants (2)
-
David Abrahams -
Neal Becker