Memory problem

John Machin sjmachin at lexicon.net
Mon Aug 14 15:26:25 EDT 2006


bearophileHUGS at lycos.com wrote:

> If you know that you need floats only, then you can use a typed array
> (an array.array) instead of an untyped array (a Python list):
>
> import array
> a = array.array("f")
>

Clarification: typecode 'f' stores a Python float (64-bits, equivalent
to a C double) as a 32-bit FP number (equivalent to a C float) -- with
apart from the obvious loss of precision, a little extra time being
required to convert to & fro. You may consider the trade-off
worthwhile.

Cheers,
John




More information about the Python-list mailing list