Re: [Tutor] Dictionary, integer, compression
Alan 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. Dinesh Message: 3 Date: Wed, 29 Apr 2009 17:35:53 +0100 From: "Alan Gauld" Subject: Re: [Tutor] Dictionary, integer, compression To: tutor@python.org Message-ID: Content-Type: text/plain; format=flowed; charset="iso-8859-1"; reply-type=original "Dinesh B Vadhia" 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? HTH -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Dictionary, integer, compression
Dinesh B Vadhia 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? Integer objects are not special cased in dictionaries. They are stored as normal int/long objects. Dictionaries do not use any kind of compression in Python. Stefan ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Dictionary, integer, compression
"Dinesh B Vadhia" 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? HTH -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] Dictionary, integer, compression
This could be a question for the comp.lang.python list but I'll try here first: 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? Dinesh ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor