Path: csiph.com!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail From: Chris Angelico Newsgroups: comp.lang.python Subject: Re: Storing a big amount of path names Date: Fri, 12 Feb 2016 11:39:32 +1100 Lines: 24 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: news.uni-berlin.de BnfYKUUaRo8JkL8HazC+cQTJAga5bD+OTldwi5PnhpHA== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.022 X-Spam-Evidence: '*H*': 0.96; '*S*': 0.00; 'received:209.85.223': 0.03; 'cc:addr:python-list': 0.09; 'throw': 0.09; 'stored': 0.10; '(shortest': 0.16; '2016': 0.16; 'dirnames': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'pathnames': 0.16; 'paulo': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'wrote:': 0.16; 'memory': 0.17; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'am,': 0.23; 'feb': 0.23; 'header:In-Reply-To:1': 0.24; 'fri,': 0.27; 'message- id:@mail.gmail.com': 0.27; 'idea': 0.28; 'objects': 0.29; 'common': 0.33; 'ram': 0.33; 'received:google.com': 0.35; 'nothing.': 0.35; 'path': 0.35; 'but': 0.36; 'there': 0.36; 'received:209.85': 0.36; 'subject:: ': 0.37; 'being': 0.37; '12,': 0.37; 'virtual': 0.38; 'received:209': 0.38; 'names': 0.38; 'stuff': 0.38; 'skip:p 20': 0.38; 'still': 0.40; 'share': 0.61; 'more': 0.63; 'different': 0.63; 'where:': 0.66; 'computers': 0.70; 'obvious': 0.76; 'chrisa': 0.84; 'have?': 0.84; 'to:none': 0.91; 'afford': 0.91 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=2AP9x3ji4DMLz+lZl+p9Bt9uwRUWyXcNK4RcXlGDgEI=; b=BcIV8n1LbnPmxZczmDy6vvfej8txsGc5I1Gb/1w7W7v/sq5svpvODwJRXpMo1EwAUt 8/m9hhP6Bi2SrHiCrnQv/Ueh3lujIlPOISuJdizeNabkx4Mh5+rCmRfhjZL46JbqUM+b RFon0mret09JbWaC7CUtMMVFvKMkcbgIdCzqLKcIH2Y+qwj8q/yk19Dqzz8DVAd11lg5 LfYUPROuGetoG10m6pGB7v422bI/pHRhE3sA5O5+pKCYTMVqr3d6v0DUxFOPbISDF6ge qvfy5Ifh4CVaIB/qiICBpjOJD4YoItGhAt2f/ftBS10VfhfANt8tG933vzaZWMzskngy gjRA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:cc:content-type; bh=2AP9x3ji4DMLz+lZl+p9Bt9uwRUWyXcNK4RcXlGDgEI=; b=nF4/ovoh6fHrqi5hg8pDVHBcsS+P0l202n9qpZidTyEhPEYl6tUnVDUyGdpzcnquf6 TYHL1KKLXfMIkvKOotcuYkYvT5b9W6dce6bRlH0hKy1RZ/sXFj5ruWLYVqYLodyDbV5q n2Ec2AL8BIa1TqZpwVsrHg53PTWUjK9fxIy4s6V8a1bwZJcrjcJ82dSrhKVEtPFcRAfz NgDZGM3DijaXkUnhz/ob0zH9J0l4kp2rl1H+cWOmneONJrevIEvSIib/k2qGey95IKXA kvi1OF7YxuwTaApOckb6wSMnXUf2EcngLW4wqGSudAPXt+aEjm2JQQbMnl1tNggaSbms dDeA== X-Gm-Message-State: AG10YOSN+3dMyxAt+txtCHy+Dyh/nAZhBbfKOw+lRBiWsaMpIqg9tjjXGv+kCgQUUhnanWxDOe76HTfs6M3e1g== X-Received: by 10.107.47.162 with SMTP id v34mr44615288iov.19.1455237572715; Thu, 11 Feb 2016 16:39:32 -0800 (PST) In-Reply-To: X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.21rc2 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com comp.lang.python:102834 On Fri, Feb 12, 2016 at 11:31 AM, Paulo da Silva 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 > self.name - > getPathname(self) - > 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. ChrisA