Path: csiph.com!aioe.org!.POSTED!not-for-mail From: Paulo da Silva Newsgroups: comp.lang.python Subject: Storing a big amount of path names Date: Fri, 12 Feb 2016 00:31:14 +0000 Organization: Aioe.org NNTP Server Lines: 35 Message-ID: NNTP-Posting-Host: rpgRlhg9tMo1Vs7b/IQ9OA.user.gioia.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.5.1 X-Enigmail-Draft-Status: N1110 X-Mozilla-News-Host: news://nntp.aioe.org:119 X-Notice: Filtered by postfilter v. 0.8.2 Xref: csiph.com comp.lang.python:102833 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 - getPathname(self) - 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