How to implement a union (C data type) in Python?
Bob Ippolito
bob at redivi.com
Mon Mar 8 11:12:10 EST 2004
On 2004-03-08 10:53:59 -0500, lamote1 at netscape.net (chads) said:
> How would one implement a union (C data type) in Python, given this
> simple example?
>
> union {
> struct {
> int size;
> float time;
> } var1;
> struct {
> char initial;
> float time;
> } var2;
> };
Why exactly do you want this? Yes, it matters.
Since you haven't inserted padding manually, this isn't necessarily a
simple example because it depends on the way the C compiler has decided
to pack structures. Behavior of this union is architecture and
compiler-flag dependent..
-bob
More information about the Python-list
mailing list