Re: feature request for setting _pack_ to a higher value
Axel Seibert <[email protected]>
| Newsgroups | gmane.comp.python.ctypes |
|---|---|
| Message-ID | <[email protected]> |
Dear list! My quest continues... During this weekend, I learned a lot about C data structures, more than I ever wanted to. After all, that's why I'm using Python. It's surprising to learn that the alignment under Linux (32bit) is different from Windows (32bit) and Solaris (32bit). Basically, now I have a feature request: The library I'm wrapping is available under different plattforms (Windows, Linux, Solaris, AIX and HP/UX). As this library contains the code to talk to a server across the network, it probably tries to keep alignment across all plattforms the same. At least, under Linux, I had to change the alignment of many structs. When I tried to do this with the class variable _pack_, I could not get the desired result; up to a value of 4 I saw a difference, but not beyond. Then I found the following statement from Thomas: > To force an alignment that is larger than the native alignment, you > must use padding. But that's not really an option. The supporting header files define 293 struct's; in 44 cases, I had to change the alignment from 4 to 8 -- but ctypes does not allow for this. And then I found a patch from Thomas that introduced that packing -- this showed me the right direction. As soon as I replaced in field cfield.c the line > align = min (pack, dict->align) with > align = pack I could specify _pack_ with values higher than 4 and align the Linux version of the library with its Windows pendant. I guess there are reasons for this min check. I have no idea about possible risks, using a too high _pack_ value. On the other hand, _pack_ is currently not a very well documented feature (it only talks about setting it to a "positive integer"), so you could assume that one should know what one is doing... I'd like to suggest that this check in setting the alignment be dropped. Thoughts? Remarks? Thanx for following me so far, Axel ------------------------------------------------------------------------------ Download Intel® Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev _______________________________________________ ctypes-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/ctypes-users