Writing some floats in a file in an efficient way

Peter Heitzer peter.heitzer at rz.uni-regensburg.de
Wed Feb 21 09:51:14 EST 2018


ast <none at gmail.com> wrote:
>Hello

>I would like to write a huge file of double precision
>floats, 8 bytes each, using IEEE754 standard. Since
>the file is big, it has to be done in an efficient
>way.

>I tried pickle module but unfortunately it writes
>12 bytes per float instead of just 8.

>Is there a way to write a float with only 8 bytes ?

Use struct.pack()

-- 
Dipl.-Inform(FH) Peter Heitzer, peter.heitzer at rz.uni-regensburg.de



More information about the Python-list mailing list