How to use a 5 or 6 bit integer in Python?
Hartmut Goebel
h.goebel at crazy-compilers.com
Sat Dec 20 07:22:33 EST 2003
Hi,
Glen Wheeler wrote:
> 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.
I'm afraid, I'll mix up some of your data-structure, but here are my
thoughts:
- pack the key-tuples into a string using pack; you may even pack 4
intergers into one byte since the values range from 1-64 (which is
equivalent to 0-63).
- if you need easy access to eg. the last emlement of the tuple, keep it
seperate. Eg: key = ('xdef', 12)
- As far as I remeber, you wrote something about max. 64 entries. What
about using an array/list here? Array may need a lot less memory
(depending on the muber of elements of course).
Only my 2 cents.
--
Regards
Hartmut Goebel
| Hartmut Goebel | We build the crazy compilers |
| h.goebel at crazy-compilers.com | Compiler Manufacturer |
More information about the Python-list
mailing list