HI folks,
There is some discussion on mpl-dev about whether/how to use Cython as
a core technology in Matplotlib.
As part of this, someone posted a Cython wrapper of the libpng lib, to
compare with a hand-coded C wrapper. However, to my eyes at least,
Cython was used at a lower level than need be (making calls to the
CPython API that Cython may take care of for you), so I'm trying to
simplify it a bit.
One issue:
How to get a pointer to pass to a C function expecting a stdio.FILE*.
He's got some python-version dependent code that seems to work, but I
suspect that Cython may well know how to do this built in. So, is
there a slightly easier way to write:
cdef stdio.FILE* fp
if PyFile_CheckExact(file_obj):
fp = PyFile_AsFile(file_obj)
the_c_function(..., fp, ...)
granted, that's not that hard, but particularly as it's different for
Py3, it would be nice to simply do:
cdef PyFile file_obj
the_c_function(..., file_obj, ...)
and have Cython do the checking, etc for me.
I couldn't find anything in the Wiki or googling, but this can't be a rare need.
-thanks,
-Chris
--
Christopher Barker, Ph.D.
Oceanographer
Emergency Response Division
NOAA/NOS/OR&R
(206) 526-6959 voice
7600 Sand Point Way NE
(206) 526-6329 fax
Seattle, WA 98115
(206) 526-6317 main reception
Chris....@noaa.gov