sizeof(struct timeval)

Nick Kew nick at
Tue Mar 14 09:17:38 CET 2006

Tony Houghton wrote:
> 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)

I've no idea.

But regardless of whether it's 'safe' amongst current devices,
you're setting yourself up for a Y2K-family bug.  Except it'll
be a real one, not a storm-inna-teacup.

My python isn't up to sizeof issues either, so I can't help
you there.  Either figure it out, or do it in C.

Nick Kew

More information about the Python-list mailing list