Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #29361

Re: Python garbage collector/memory manager behaving strangely

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.001
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'subject:Python': 0.05; 'chunk': 0.07; 'exit': 0.07; 'function,': 0.07; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'seen,': 0.09; 'sep': 0.09; '(last': 0.16; 'chunk:': 0.16; 'cleaner': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'true:': 0.16; 'mon,': 0.16; 'specify': 0.17; 'hack': 0.18; 'header:X-Complaints-To:1': 0.28; 'lines': 0.28; 'rest': 0.28; 'subject:/': 0.28; 'character': 0.29; 'attach': 0.30; 'could': 0.32; 'function.': 0.33; 'url:home': 0.33; 'to:addr:python-list': 0.33; 'sometimes': 0.35; 'there': 0.35; 'received:org': 0.36; 'but': 0.36; 'characters': 0.36; 'should': 0.36; 'charset:us-ascii': 0.36; 'itself': 0.37; 'previous': 0.37; 'data': 0.37; 'subject:: ': 0.38; 'to:addr:python.org': 0.39; 'header:Received:5': 0.40; 'end': 0.40; 'middle': 0.66; 'dennis': 0.91
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Dennis Lee Bieber <wlfraed@ix.netcom.com>
Subject Re: Python garbage collector/memory manager behaving strangely
Date Mon, 17 Sep 2012 00:15:45 -0400
Organization > Bestiaria Support Staff <
References <CEE8C35195DB944D9C75ABB15A04193B14E77085@EHKG17P32001A.csfb.cs-group.com> <5056871E.7050206@davea.name> <CEE8C35195DB944D9C75ABB15A04193B14FD2646@EHKG17P32001A.csfb.cs-group.com>
Mime-Version 1.0
Content-Type text/plain; charset=us-ascii
Content-Transfer-Encoding 7bit
X-Gmane-NNTP-Posting-Host adsl-76-249-16-53.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 <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.821.1347855354.27098.python-list@python.org> (permalink)
Lines 36
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1347855354 news.xs4all.nl 6884 [2001:888:2000:d::a6]:56384
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:29361

Show key headers only | View raw


On Mon, 17 Sep 2012 10:28:34 +0800, "Jadhav, Alok"
<alok.jadhav@credit-suisse.com> declaimed the following in
gmane.comp.python.general:


> - As you have seen, the line separator is not '\n' but its '|\n'.
> Sometimes the data itself has '\n' characters in the middle of the line
> and only way to find true end of the line is that previous character
> should be a bar '|'. I was not able specify end of line using
> readlines() function, but I could do it using split() function.
> (One hack would be to readlines and combine them until I find '|\n'. is
> there a cleaner way to do this?)

	Then chunk the file... 

{PSEUDOCODE}

last = ""
while True:
	chunk = fin.read(500000)		#read 1/2 MB max
									#and attach to left-overs
	if not chunk:		#EOF, process any left overs
		processLine(last)
		break			#and exit
	
	lines = (last + chunk).split("|\n")
	last = lines[-1]					#save "partial" line

	for ln in lines[:-1]:				#loop over rest
		processLine(ln)

fin.close()
-- 
	Wulfraed                 Dennis Lee Bieber         AF6VN
        wlfraed@ix.netcom.com    HTTP://wlfraed.home.netcom.com/

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: Python garbage collector/memory manager behaving strangely Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2012-09-17 00:15 -0400

csiph-web