Path: csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!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.003 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'output': 0.05; 'variables': 0.07; 'indexes': 0.09; 'lines.': 0.09; 'posting.': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'python': 0.11; 'wrote': 0.14; 'chunks.': 0.16; 'manageable': 0.16; 'merged': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'script?': 0.16; 'sequential': 0.16; 'fix': 0.17; 'trying': 0.19; 'items.': 0.19; 'later': 0.20; 'memory': 0.22; 'merge': 0.24; 'file.': 0.24; 'header:X-Complaints-To:1': 0.27; 'point': 0.28; 'said,': 0.30; 'gives': 0.31; 'lines': 0.31; 'usually': 0.31; 'concern.': 0.31; 'operations.': 0.31; 'subject:size': 0.31; 'file': 0.32; 'text': 0.33; 'bugs': 0.33; 'actual': 0.34; 'knows': 0.35; 'add': 0.35; 'should': 0.36; 'list': 0.37; 'to:addr:python- list': 0.38; 'files': 0.38; 'track': 0.38; 'to:addr:python.org': 0.39; 'either': 0.39; 'received:org': 0.40; 'how': 0.40; 'complete': 0.62; 'sum': 0.64; 'more': 0.64; 'taking': 0.65; 'limit': 0.70; 'gain': 0.79; 'algorithm,': 0.84; 'afford': 0.91; 'picture': 0.97 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Dave Angel Subject: Re: Finding size of Variable Date: Tue, 4 Feb 2014 08:09:00 -0500 (EST) Organization: news.gmane.org References: <8e4c1ab1-e65d-483f-ad9d-6933ae2052c3@googlegroups.com> <2728aca8-735b-4c38-9e7e-a164e8ed36f9@googlegroups.com> X-Gmane-NNTP-Posting-Host: dpc6744192073.direcpc.com X-Newsreader: PiaoHong Usenet NewsReaders 1.36 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: 34 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1391519162 news.xs4all.nl 2852 [2001:888:2000:d::a6]:34052 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:65420 Ayushi Dalmia Wrote in message: >> getsizeof() gives you the size of the list only; to complete the picture you >> >> have to add the sizes of the lines. >> >> >> >> However, why do you want to keep track of the actual memory used by >> >> variables in your script? You should instead concentrate on the algorithm, >> >> and as long as either the size of the dataset is manageable or you can limit >> >> the amount of data accessed at a given time you are golden. > > As I said, I need to merge large files and I cannot afford more I/O operations. So in order to minimise the I/O operation I am writing in chunks. Also, I need to use the merged files as indexes later which should be loaded in the memory for fast access. Hence the concern. > > Can you please elaborate on the point of taking lines into consideration? > Please don't doublespace your quotes. If you must use googlegroups, fix its bugs before posting. There's usually no net gain in trying to 'chunk' your output to a text file. The python file system already knows how to do that for a sequential file. For list of strings just add the getsizeof for the list to the sum of the getsizeof of all the list items. -- DaveA