[Tutor] Dictionary, integer, compression

Dinesh B Vadhia dineshbvadhia at hotmail.com
Wed Apr 29 20:36:22 CEST 2009


I want to perform test runs on my local machine with very large numbers of integers stored in a dictionary.  As the Python dictionary is an built-in function I thought that for very large dictionaries there could be compression.  Done correctly, integer compression wouldn't affect performance but could enhance it.  Weird, I know!  I'll check in with the comp.lang.python lot.



Message: 3
Date: Wed, 29 Apr 2009 17:35:53 +0100
From: "Alan Gauld" <alan.gauld at btinternet.com>
Subject: Re: [Tutor] Dictionary, integer, compression
To: tutor at python.org
Message-ID: <gt9vl7$oh4$1 at ger.gmane.org>
Content-Type: text/plain; format=flowed; charset="iso-8859-1";

"Dinesh B Vadhia" <dineshbvadhia at hotmail.com> wrote

> Say, you have a dictionary of integers, are the integers stored 
> in a compressed integer format or as integers ie. are integers 
> encoded before being stored in the dictionary and then 
> decoded when read?

I can't think of any reason to compress them, I imagine they 
are stored as integers. But given the way Python handlers 
integers with arbitrarily long numbers etc it may well be more 
complex than a simple integer (ie 4 byte number). But any 
form of compression would be likely to hit performamce 
so I doubt that they would be compressed.

Is there anything that made you think they might be?


Alan Gauld
Author of the Learn to Program web site

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20090429/e02220dd/attachment.htm>

More information about the Tutor mailing list