sizeof(struct timeval)

Tony Houghton at
Tue Mar 14 02:13:56 CET 2006

I'm writing a python program which reads input device events so it needs
to know sizeof(struct timeval). By using the struct module I should be
able to work out sizeof(long) from python, but I can't think of a way to
measure non-fundamental types without including a little bit of C,
which I'd rather avoid.

How safe would I be assuming that 

    sizeof(struct timeval) == 2 * sizeof(long)

is always true on Linux on different architectures? AFAIK the input
device interface is Linux-specific so I don't need to worry about other

The address in the Reply-To is genuine and should not be edited.
See <> for more reliable contact addresses.

More information about the Python-list mailing list