[Pyrex] Question

Greg Ewing greg at cosc.canterbury.ac.nz
Thu Apr 17 01:35:46 CEST 2003


Riccardo Trocca <rtrocca at libero.it>:

> For example I've got #define RIMAGE_BGR24 0x8001.
> I declared it in the import part of the pyx file because I need it =
> inside the pyrex code.
> Now what can I do in order to mymodule.RIMAGE_BGR24?

If you assign it to a module-level variable, it will
be accessible from Python.

To get it to have the same name, you'll need to make
use of a feature I added recently for renaming things:

  cdef extern from "something.h":
    cdef enum:
      C_RIMAGE_BGR24 "RIMAGE_BGR24"

  RIMAGE_BGR24 = C_RIMAGE_BGR24

You've now got two different names defined in Pyrex:
C_RIMAGE_BGR24, which is a C constant, and
RIMAGE_BGR24 which is a module-level Python variable.

Inside the Pyrex file, you should use C_RIMAGE_BGR24
whenever you need it in a C context, since it'll be
faster.

Greg Ewing, Computer Science Dept, +--------------------------------------+
University of Canterbury,	   | A citizen of NewZealandCorp, a	  |
Christchurch, New Zealand	   | wholly-owned subsidiary of USA Inc.  |
greg at cosc.canterbury.ac.nz	   +--------------------------------------+




More information about the Pyrex mailing list