Memory efficient tuple storage

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Fri Mar 13 20:05:07 CET 2009


En Fri, 13 Mar 2009 14:49:51 -0200, Tim Wintle <tim.wintle at teamrubber.com>  
escribió:

> If the same chromosome string is being used multiple times then you may
> find it more efficient to reference the same string, so you don't need
> to have multiple copies of the same string in memory. That may be what
> is taking up the space.
>
>
> i.e. something like (written verbosely)
>
> reference_dict = {}
> for (chromosome,posn) in my_file:
>     chromosome = reference_dict.setdefault(chromosome,chromosome)

Note that the intern() builtin does exactly that: chromosome =  
intern(chromosome)

-- 
Gabriel Genellina




More information about the Python-list mailing list