On Fri, Oct 11, 2013 at 10:46 AM, Stefan Behnel <stefan...@behnel.de> wrote: > Robert Bradshaw, 11.10.2013 19:10: >> Python and Cython in >> general breaks pointer aliasing as objects are simultaneously generic >> PyObject* and PyListObject*, PyDictObject*, etc. As the set of >> possible types is large and open, unions won't work. This is how >> object oriented programming (with subclassing) is done in C. > > This has been fixed in CPython 3.x.
Ah, I wasn't even aware of that. For the curious: http://www.python.org/dev/peps/pep-3123/ Basically, there is an exception for casting a struct pointer to a pointer of its first member. Looking into this more, there's also an exception for char* (aliasing is explicitly allowed), so I take back what I said about this not being possible (due to the looseness of "strict" aliasing in some cases) but I don't know how easy it'd be. - Robert _______________________________________________ cython-devel mailing list cython-devel@python.org https://mail.python.org/mailman/listinfo/cython-devel