Robert Bradshaw wrote: > On Apr 9, 2008, at 8:25 AM, Martin C. Martin wrote: >> Hi, >> >> There's a potential optimization I mentioned on the Lisp inspired >> transforms page, where you could reorder bitfields in order to pack them >> most efficiently. Eerily, someone at my job just committed something >> that did just that. We have a custom defstruct, called defstruct-bv, >> which allows you to specify bit fields. (Lisp doesn't come with >> bitfields.) Here's the checkin message: >> ... > > I believe in Cython we would just rely on the C compiler to make > optimizations of this nature.
That's the point, C prescribes that it *can't* make such optimizations. C fields (including bitfields) must appear in memory in the order they appear in the source code. For bit fields, this is an advantage when you're, say, parsing the header of some binary file, or writing a device driver. But if you just want a struct that stores some data compactly, the C compiler can't help you out in that case. Best, Martin _______________________________________________ Cython-dev mailing list [email protected] http://codespeak.net/mailman/listinfo/cython-dev
