[Pyrex] self-referencing extension types

Nitin Madnani nmadnani at wam.umd.edu
Wed Sep 21 06:32:41 CEST 2005


Sorry to flood the mailing list with my questions but how do I do  
something like this in pyrex with extension types:

cdef extern from "foo.h":
     ctypedef struct stack:
         long n
         double f
         stack* s

def test():
     cdef stack s1, s2
     cdef stack* s3

     s1.n = 33
     s1.f = 4.5

     s2.n = 34
     s2.f = 5.6

     # They point to each other
     s1.s = &s2
     s2.s = &s1

     # See if it worked ..
     s3 = s1.s
     print s3.n


This does work fine but I was curious if there is an equivalent way  
to this sort of self-referential thing using extension types.
Thanks !
Nitin



More information about the Pyrex mailing list