How to turn a string into a list of integers?

Roy Smith roy at panix.com
Sun Sep 7 17:40:57 CEST 2014


In article <mailman.13850.1410102277.18130.python-list at python.org>,
 Chris Angelico <rosuav at gmail.com> wrote:

> You can't store a list in memory; what you store is a set of bits 
> which represent some metadata and a bunch of pointers.


Well, technically, what you store is something which has the right 
behavior.  If I wrote:

my_huffman_coded_list = [0] * 1000000

I don't know of anything which requires Python to actually generate a 
million 0's and store them somewhere (even ignoring interning of 
integers).  As long as it generated an object (perhaps a subclass of 
list) which responded to all of list's methods the same way a real list 
would, it could certainly build a more compact representation.



More information about the Python-list mailing list