how to store great array?

paulus132 at my-deja.com paulus132 at my-deja.com
Tue Jan 30 18:02:33 EST 2001


Many thanks for your help!

With the Posix arguments of ps, I can follow the memory used by Python
for same great objects:

import os
os.system("ps -o pid,ppid,vsz,etime,time,comm")

And with array.array('h'), I can verify that each entry "costs" exactly
2 bytes !

But for a standard list of integers, each entry seems costing something
between 16 and 20 bytes !

Array is a good solution for my problem and Python a wonderful language,
wich offer so flexible solutions!

Paul Perrin


In article <slrn97cccp.30e.jepler at potty.housenet>,
  jepler at inetnebr.com (Jeff Epler) wrote:

> If your document numbers are contiguous and you have decided on
in-memory
> storage, [1934, 1942, ...], a list of integers rather than strings,
> is one choice.  Another is the "array" module, which will offer the
> lowest overhead.  For instance, you can select a type of "byte" (If
> all your documents are expected to fall within a 256-year timespan)
> or go all the way to "int" (4 billion year range).  This storage
method is
> as efficient as a C array, except for a few bytes of overhead.  2
million


Sent via Deja.com
http://www.deja.com/



More information about the Python-list mailing list