Path: csiph.com!usenet.pasdenom.info!dedibox.gegeweb.org!gegeweb.eu!nntpfeed.proxad.net!proxad.net!feeder1-2.proxad.net!news.tele.dk!news.tele.dk!small.news.tele.dk!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.062 X-Spam-Evidence: '*H*': 0.88; '*S*': 0.00; 'plenty': 0.07; 'subject:file': 0.07; 'used.': 0.09; 'python': 0.11; '-tkc': 0.16; '.txt': 0.16; 'from:addr:python.list': 0.16; 'from:addr:tim.thechases.com': 0.16; 'from:name:tim chase': 0.16; 'sqlite': 0.16; 'subject: \n ': 0.16; 'files.': 0.16; 'wrote:': 0.18; 'things.': 0.19; 'load': 0.23; 'aspect': 0.24; 'config': 0.24; 'sort': 0.25; 'switch': 0.26; 'subject:/': 0.26; 'asking': 0.27; 'gets': 0.27; 'header:In-Reply-To:1': 0.27; 'wondering': 0.29; "doesn't": 0.30; "i'm": 0.30; 'file': 0.32; 'checked': 0.32; 'text': 0.33; 'except': 0.35; 'really': 0.36; 'accessing': 0.36; 'disk': 0.36; 'charset:us-ascii': 0.36; 'subject:?': 0.36; 'to:addr:python-list': 0.38; 'files': 0.38; 'issue': 0.38; 'does': 0.39; 'sure': 0.39; 'to:addr:python.org': 0.39; 'either': 0.39; 'even': 0.60; 'most': 0.60; "you'll": 0.62; 'places': 0.64; 'subject:more': 0.64; 'more': 0.64; 'benefit': 0.68; 'atomic': 0.84; 'configparser': 0.84; 'nfs': 0.84; 'received:50.22': 0.84; 'subject:read': 0.84; 'plain-text': 0.91; 'shares': 0.93 Date: Sat, 14 Dec 2013 10:15:18 -0600 From: Tim Chase To: python-list@python.org Subject: Re: Is it more CPU-efficient to read/write config file or read/write sqlite database? In-Reply-To: References: X-Mailer: Claws Mail 3.8.1 (GTK+ 2.24.10; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - boston.accountservergroup.com X-AntiAbuse: Original Domain - python.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tim.thechases.com X-Get-Message-Sender-Via: boston.accountservergroup.com: authenticated_id: tim@thechases.com X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 29 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1387037653 news.xs4all.nl 2966 [2001:888:2000:d::a6]:42343 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:61903 On 2013-12-14 07:29, JL wrote: > I have a number of python processes which communicate with each > other through writing/reading config text files. The python > ConfigParser is used. I am wondering if it is more CPU-efficient to > switch to using sqlite database instead of using configuration > files. If the software does plenty of reading/writing, is it more > efficient to use config text files or sqlite database? I'm pretty sure that the CPU aspect doesn't really play into things. A few thoughts: + You'll be I/O bound most of the time. Even if you used a ramdisk to reduce disk access delays, accessing multiple .txt files requires the OS to do permission-checking each time, while a single sqlite file gets checked once upon opening the DB initially. + text-files are fragile unless you take extra pains to keep things atomic + sqlite guarantee* atomicity, so you either see all-or-nothing + sqlite is also very efficient for querying + sticking with plain-text config files is just asking for some sort of race-condition or partial-file issue to come up + sqlite may give you less CPU load is just an added benefit -tkc * well, except on NFS shares and other places where file-locking is unreliable