Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!newsfeed.xs4all.nl!newsfeed6.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.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'output': 0.04; 'subject:Python': 0.05; 'binary': 0.05; 'diff': 0.05; 'algorithms,': 0.07; 'chunk': 0.07; 'file)': 0.07; 'lines.': 0.07; 'parsing': 0.07; 'python': 0.09; 'counting': 0.09; 'files:': 0.09; 'internally': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'splitting': 0.09; 'subject:not': 0.11; 'source,': 0.15; '"n"': 0.16; '(assuming': 0.16; 'in-memory': 0.16; 'matlab': 0.16; 'oct': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'string,': 0.17; 'thanks,': 0.18; '(in': 0.18; 'memory': 0.18; 'load': 0.19; '(not': 0.20; 'written': 0.20; 'sort': 0.21; 'work.': 0.23; 'statement': 0.23; 'seems': 0.23; 'merge': 0.27; "doesn't": 0.28; 'header:X-Complaints-To:1': 0.28; 'lines': 0.28; 'run': 0.28; 'array': 0.29; 'convert': 0.29; 'related': 0.30; 'e.g.': 0.30; 'fri,': 0.30; 'saves': 0.30; 'file': 0.32; 'mass': 0.33; 'url:home': 0.33; 'to:addr:python-list': 0.33; 'operations': 0.33; 'another': 0.33; 'data,': 0.35; 'there': 0.35; 'next': 0.35; 'received:org': 0.36; 'but': 0.36; 'compare': 0.36; 'charset:us- ascii': 0.36; 'enough': 0.36; 'does': 0.37; 'option': 0.37; 'data': 0.37; 'subject:: ': 0.38; 'files': 0.38; 'some': 0.38; 'to:addr:python.org': 0.39; 'header:Received:5': 0.40; 'first': 0.61; 'back': 0.62; 'time,': 0.62; 'repeat': 0.62; 'show': 0.63; 'fulfill': 0.65; 'biggest': 0.71; 'url:help': 0.72; '1gb': 0.84; 'amount.': 0.84; 'seldom': 0.84; 'dennis': 0.91; 'subject:available': 0.96 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Dennis Lee Bieber Subject: Re: Python does not take up available physical memory Date: Fri, 19 Oct 2012 20:40:19 -0400 Organization: > Bestiaria Support Staff < References: <76D03718A3233B4C8CC236C169B535B5A23E063E45@AUSP01VMBX08.collaborationhost.net> <5081d04b$0$30003$c3e8da3$5496439d@news.astraweb.com> <76D03718A3233B4C8CC236C169B535B5A23E063F6B@AUSP01VMBX08.collaborationhost.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: adsl-76-249-17-7.dsl.klmzmi.sbcglobal.net X-Newsreader: Forte Agent 3.3/32.846 X-No-Archive: YES 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: 1350693637 news.xs4all.nl 6845 [2001:888:2000:d::a6]:50890 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:31787 On Fri, 19 Oct 2012 17:20:23 -0500, Pradipto Banerjee declaimed the following in gmane.comp.python.general: > Thanks, for the illustration. This seems to be one of the biggest shortcomings of Python vs. Matlab. A number of people told me to read one line at a time, but I have a need to run processes on the whole data, e.g. compare one line versus another. So that option doesn't work. And that requirement already suggests that reading the file en-mass is inappropriate... Reading a 1GB mass and THEN splitting it into lines means you have 2GB (not counting overhead) in memory for some period of time (assuming the OS found a 1GB contiguous chunk of memory). I suspect Matlab's read is internally parsing on lines. You don't show the related Matlab read statement but... http://www.mathworks.com/help/matlab/ref/fscanf.html does both the read AND the conversion to the binary array format -- it doesn't read the file as a chunk and THEN convert it to an array; it only reads enough to fulfill one "format" string, saves that conversion, then reads the next amount. Large data DIFF and SORT are seldom run as in-memory operations -- they work line-by-line using files (in the case of some SORT algorithms, many files: load 50-100 lines from source, sort in-memory, write to file-1; repeat for file-2, -3, ... -n; when you have written to "n" files, start back with the first file... Then do an -n file merge to another n-files... Repeat until there is only one output file) -- Wulfraed Dennis Lee Bieber AF6VN wlfraed@ix.netcom.com HTTP://wlfraed.home.netcom.com/