On Jun 23, 2009, at 4:44 AM, Dag Sverre Seljebotn wrote: > Jon Olav Vik wrote: >> Jon Olav Vik <jono...@...> writes: >>> == cynvector.pxd == >>> from sundials cimport * # sundials.pxd defines N_Vector >>> cdef class CythonNVector: >>> cdef N_Vector nvector >>> cpdef toarray(self) >>> == cynvector.pyx == >> [...] >>> cdef class CythonNVector: >>> cdef N_Vector nvector # <-- ERROR >> [...] >> >> Gotcha: When I copied declarations from cynvector.pyx to >> cynvector.pxd, I >> should have removed the original "cdef N_Vector nvector" from >> the .pyx file. As >> it was, I got a "'nvector' redeclared" error when re-compiling my >> example. The >> reason I didn't see it at first is that I compiled cynvector.so >> just from >> cynvector.pyx first, before creating cynvector.pxd. >> >> To summarize: "Formal" declarations of object attributes in >> filename.pxd are >> automatically available in filename.pyx and should not be repeated >> there. >> (Functions and class definitions _are_ repeated, for implementation.) > > This confused me a lot too when I met it the first time. Could we > change > this? That is, I think we should start silently accept/ignore > repeating > the declaration of cdef class fields (and module global variables?) in > the pyx -- this should be backwards compatible.
I'm not opposed to such a change. Errors, of course, on non-matching and extra fields. - Robert _______________________________________________ Cython-dev mailing list [email protected] http://codespeak.net/mailman/listinfo/cython-dev
