C Module question
boblatest at googlemail.com
boblatest at googlemail.com
Mon Nov 10 08:44:44 EST 2008
On Nov 10, 2:23 pm, Floris Bruynooghe <floris.bruynoo... at gmail.com>
wrote:
> Sorry, I probably should have mentioned you want to cast the object to
> PyFileObject and then use the PyFile_AsFile() function to get the
> FILE* handle.
Yes, I figured that out by now. Sadly this doesn't work on "file-like"
objects like those that are created by opening bz2 files (using the
bz2 lib). Not that I have any idea on how that should work anyway.
I still can resolve this issue in my wrapper module and let the C part
deal with the raw buffer contents.
All in all I must say that implementing a C extension is a piece of
cake. Had I known that it was this straightforward I wouldn't have
asked my questions in the first place. Making the whole thing more
robust will be a bit more difficult, and I need to find out how to
deal with ressources that are dynamically allocated on the C side.
But that should be easy, and I'll just keep all the Python OO and
Exceptions stuff in the wrapper and call my C stuff from there in a
more or less straightforward C manner.
Thanks to everybody for helping out,
robert
(I'll be back for sure)
More information about the Python-list
mailing list