Hi,

I am in the midst of porting a project to Cython, and have run into a
few issues.  I had been using Pyrex 0.9.8.4 and am trying the latest
public release of Cython (0.9.8.1.1).  I'm interfacing to the HDF5 C
library, which has a huge API.  Since I heard Cython (unlike Pyrex)
supports "cimport *", I wanted consolidate the whole thing into
"hdf5.pxd" and simply cimport everything into each module I'm building.
However, this doesn't seem to import typedefs:

# file "ext.pxd":
cdef extern from "something.h":
   ctypedef int INT

# file "implementation.pyx":
from ext cimport *
def foo():
    cdef INT q = 1
    print q

This fails with a syntax error.  If I replace the cimport line with
"from ext cimport INT" it works fine.  Is this a bug or an intentional
limitation (or am I using it wrong)?

The second issue is that Cython.Compiler.Main.compile_multiple doesn't
work if you use either the "recursive" or "timestamps" options; I get a
NameError referring to what seems to be a missing global variable
"context" inside Cython itself:

/usr/lib/python2.5/site-packages/Cython/Compiler/Main.py in
compile_multiple(sources, options)
    639             # Compiling multiple sources in one context doesn't
quite
    640             # work properly yet.
--> 641             if not timestamps or
context.c_file_out_of_date(source):
    642                 if verbose:
    643                     sys.stderr.write("Compiling %s\n" % source)

<type 'exceptions.NameError'>: global name 'context' is not defined

I'd like to eventually use this if possible because it lets me run
Cython from a setup script independent of the actual C build process.
Will this be fixed in a later version of Cython?

Finally I noticed that Cython doesn't have the new Pyrex "typecheck"
builtin.  I've switched back to "isinstance" for now.  Is there/will
there be a Cython equivalent?

Other than that everything works!  Thanks in particular for the
decorator support, which is the main reason I'm switching.

Andrew Collette








_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to