Storing a big amount of path names

Paulo da Silva p_s_d_a_s_i_l_v_a_ns at
Thu Feb 11 19:31:14 EST 2016


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

class MyFile:


  def __init__(self,dirname,filename):
    self.dirname=dirname  # But I want to share this with other files

  def getPathname(self):
    return os.path.join(self.dirname,


Thanks for any suggestion.

More information about the Python-list mailing list