[capi-sig] C functions that modify their arguments.
philip at semanchuk.com
Tue Feb 28 14:58:10 CET 2012
On Feb 27, 2012, at 2:48 PM, Wendell Nichols wrote:
> I have a library that I want to wrap for Python (as part of an exercise to learn Python, and provide some public good at the same time :) The library is proprietary and I can't change it. Many of its functions modify a pointer provided via an address arg. Can python deal with functions that modify their arguments? If so (generally) how?
> If there is no formalised way I'm may have to consider registering some sort of callback to alter the argument from within C... kind of awkward but since I'm code generating all the C so long as I have a workable approach it doesn't matter how much code it takes :)
IMO you have to be more specific about what the library does. If the library isn't Python-aware (which I guess it isn't, otherwise you wouldn't be wrapping it), then any pointers it returns won't point to Python objects. You can return those pointers to Python, but Python will just see a block of raw memory, not Python objects. This is usually not so useful.
Personally, I'm confused about what you're trying to do.
More information about the capi-sig