[Pyrex] Does __Pyx_ImportType need to check struct sizes? (Cython-relevant, too)

Greg Ewing greg.ewing at canterbury.ac.nz
Sun May 24 14:07:31 CEST 2009


Robert Kern wrote:
> What is the reasoning behind having __Pyx_ImportType check that the imported 
> type's size at runtime matches exactly the type's size at compile time?

It's meant to provide some degree of safeguard against
changing the definition of a type and failing to
recompile all the Pyrex modules that import it.

I know it's not a perfect check, but I thought it
would be better than nothing. Remember that it may
not only be you that's affected by the change, but
someone else importing your type into their Pyrex
module. Without any check, they'll just get a
segfault with no clue as to what went wrong.

Also note that adding fields to the end is only
safe in the absence of subclassing.

I might be persuaded to drop the check, but only
if everyone promises not to complain if their
Pyrex modules fail inexplicably. :-)

-- 
Greg



More information about the Pyrex mailing list