<table cellspacing="0" cellpadding="0" border="0" ><tr><td valign="top" style="font: inherit;">Thanks for the explanation. Btw, How can I get the size of python primitive data types in bytes? Is it defined somewhere in a file that I can look at? <br><br>--- On <b>Fri, 8/29/08, Kent Johnson <i>&lt;kent37@tds.net&gt;</i></b> wrote:<br><blockquote style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px;">From: Kent Johnson &lt;kent37@tds.net&gt;<br>Subject: Re: [Tutor] Puzzled<br>To: ceasar102@yahoo.com<br>Cc: tutor@python.org<br>Date: Friday, August 29, 2008, 4:41 PM<br><br><pre>On Fri, Aug 29, 2008 at 5:13 PM, ammar azif &lt;ceasar102@yahoo.com&gt; wrote:<br>&gt; I wrote a python program that used time() function from the time module to<br>&gt; retrieve time in seconds since Epoch. After the value was retrieved which<br>I<br>&gt; checked is a float by using type(),  the value was then written into a<br>file<br>&gt; in binary
 format. Then another C program that I wrote opened the file and<br>&gt; converted the value into a time_t variable but it was totally different<br>from<br>&gt; the correct value. Then I found that the time_t size is actually 4 byte<br>&gt; integer which is not the same with 8-byte float value returned by<br>&gt; time.time(). Why is this so? Being written with C library, isn't<br>python<br>&gt; suppose to work well with it?<br><br>The C time_t type is very loosely specified; in ANSI C it is only<br>required to be an arithmetic type. According to Wikipedia<br>(http://en.wikipedia.org/wiki/Time_t), Posix-compliant systems still<br>have latitude to implement it as 32 or 64 bits.<br><br>Python tries to be bit higher level, giving you fractional seconds if<br>the implementation supports it and a common data type across<br>implementations. So there is not an exact match in functionality.<br><br>If you want to write data to file in a format that can be read
 by<br>another program, you should look at the struct module.<br><br>Kent<br></pre></blockquote></td></tr></table><br>