[Pyrex] Possible syntax for direct cimport from C header files
John J Lee
jjl at pobox.com
Mon Jul 21 19:41:50 CEST 2003
Jumping the gun a bit, since I don't even know if Greg is interested in
cimporting from C headers...
This makes me think of a posssible syntax for cimport from C header files
(which I posted about earlier). How about only allowing exactly this
"import *" form, perhaps only in .pxd files?
from "foo/blah.h" cimport *
That would give you a typical usage of having just that one line (maybe a
couple of similar ones too, for multi-header libraries) in a .pxd, thus
wrapping the C header(s) in a namespace.
This syntax has the advantage of avoiding the complications of trying to
satisfy two goals at once: first, copying Python's dotted import syntax
(from foo.blah import *, from foo import blah, etc.), and second, allowing
for arbitrary variations in header filenames, like .hpp, .H, .c etc. It
also exactly follows the standard C preprocessor "foo/blah.h" syntax,
which makes things slightly simpler when wrapping libraries.
Of course, this could be added later if there was a need:
from "foo/blah.h" cimport SomeSymbol
John
More information about the Pyrex
mailing list