Storing a big amount of path names
Paulo da Silva
p_s_d_a_s_i_l_v_a_ns at netcabo.pt
Thu Feb 11 19:31:14 EST 2016
Hi!
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
self.name - <base name>
getPathname(self) - <full pathname>
other stuff
class MyFile:
__allfiles=[]
def __init__(self,dirname,filename):
self.dirname=dirname # But I want to share this with other files
self.name=filename
MyFile.__allfiles.append(self)
...
def getPathname(self):
return os.path.join(self.dirname,self.name)
...
Thanks for any suggestion.
Paulo
More information about the Python-list
mailing list