How to use a 5 or 6 bit integer in Python?

Glen Wheeler adsl5lcq at tpg.com.au
Sat Dec 20 03:25:34 EST 2003


On Fri, 19 Dec 2003 14:21:16 +0100, Borcis <borcis at users.ch> wrote:

>Glen Wheeler wrote:
>
>>   I'm using one dictionary to store all of the data, with tuples of
>> ints as keys and a tuple as the data associated with each key.  The
>> data tuples contain a few ints and two more dictionaries.
>>   Can you think of a way to reduce the memory used here?
>
>What's the length of the key tuples, and are there bounds on the
>component ints ?

  Component ints will either be 0-63 or 0-31.  In a single run of the
program, this will not change throughout.
  The key tuples range in length from 1-64, depending on at what stage
the program is currently at.  Every tuple will have the same length at
some point; the greatest possible distance in length from any two
tuples is 1.

> Is the number of ints in the data tuples fixed ?

  Yes, there are always two ints, and another tuple of ints.  One int
is arbitrary, and can be in the thousands but not much higher.
Another int is from 0-5.  The tuple of ints is less than 6 long and
will contain either 0-63 or 0-31, depending on the parameters given to
the program at run time.

> What's in the subdictionnaries, typically ?  "millions of 5 bit integers" hints
>of the possibility of a radical change of representation, but a radical
>change of representation can only be devised if we know what's stable
>- the task.

  Well, the subdictionaries contents are described in another reply
written by me in this same thread.  There are indeed many millions of
integers beign stored at any one time, or at least many millions of
references to these integers.
  You are saying that to save any amount of memory something in the
large dictionary must be constant?  I am sure everything in there is
dynamic in nature, i.e. will change with each iteration over the keys
in the large dictionary.

-- 
Glen




More information about the Python-list mailing list