[Pyrex] Why were .pxd files invented?

Greg Ewing greg.ewing at canterbury.ac.nz
Sat Mar 31 13:01:20 UTC 2007


Leif Strand wrote:

> I can't figure out why .pxd files were invented.

Because I want to be able to write a Makefile that can
tell whether the C-level interface of a Pyrex module has
changed, thus necessitating a recompile of any other
Pyrex modules that cimport it. With the interface and
implementation munged into a single file, that would
be much more difficult.

Also, one day I may want to attach version timestamps
to extension types so that interface mismatches can
be detected at import time instead of a crash occuring.

> why not search for the Shrubbing.pyx file, parse it,

Another reason is that the Shrubbing.pyx file is probably
much bigger than the Shrubbing.pxd file, and would take
much longer to parse. Keep in mind that Pyrex's scanner

> In any case, .pxd files 
> weren't designed to give you an interface/implementation concept to 
> begin with: all 'cdef' stuff is public (cdef declarations must appear in 
> the "interface"), you can't have "private" cdef attributes or methods.

Not all cdefs go there, only things which affect the
C-level layout of extension types. That has to be
consistent between all Pyrex modules that use it.

--
Greg




More information about the Pyrex mailing list