Storing a big amount of path names

Chris Angelico rosuav at
Thu Feb 11 19:39:32 EST 2016

On Fri, Feb 12, 2016 at 11:31 AM, Paulo da Silva
<p_s_d_a_s_i_l_v_a_ns at> wrote:
> What is the best (shortest memory usage) way to store lots of pathnames
> in memory where:
> 1. Path names are pathname=(dirname,filename)
> 2. There many different dirnames but much less than pathnames
> 3. dirnames have in general many chars
> The idea is to share the common dirnames.
> More realistically not only the pathnames are stored but objects each
> object being a MyFile containing
> - <base name>
> getPathname(self) - <full pathname>
> other stuff

Just store them in the most obvious way, and don't worry about memory
usage. How many path names are you likely to have? A million? You can
still afford to have 1KB pathnames and it'll take up no more than a
gigabyte of RAM - and most computers throw around gigs of virtual
memory like it's nothing.


More information about the Python-list mailing list