Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #31761
| Path | csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!news-out2.kabelfoon.nl!newsfeed.kabelfoon.nl!xindi.nntp.kabelfoon.nl!feed.xsnews.nl!border-2.ams.xsnews.nl!xlned.com!feeder1.xlned.com!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <rosuav@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.007 |
| X-Spam-Evidence | '*H*': 0.99; '*S*': 0.00; 'subject:Python': 0.05; 'memory.': 0.05; 'python': 0.09; 'iterate': 0.09; 'subject:not': 0.11; 'sat,': 0.15; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'instead:': 0.16; 'oct': 0.16; 'wrote:': 0.17; 'string,': 0.17; 'unicode': 0.17; 'memory': 0.18; 'windows': 0.19; 'file.': 0.20; 'trying': 0.21; 'task': 0.23; 'random': 0.24; 'tried': 0.25; 'header:In-Reply-To:1': 0.25; 'am,': 0.27; 'possibility': 0.27; '2.3': 0.27; 'converting': 0.27; 'message- id:@mail.gmail.com': 0.27; '>>>>': 0.29; 'file': 0.32; 'could': 0.32; 'to:addr:python-list': 0.33; 'received:google.com': 0.34; 'text': 0.34; 'follows:': 0.35; 'received:209.85': 0.35; 'something': 0.35; 'execute': 0.37; 'received:209': 0.37; 'subject:: ': 0.38; 'shows': 0.38; 'there,': 0.38; 'to:addr:python.org': 0.39; 'header:Received:5': 0.40; 'your': 0.60; 'more': 0.63; 'charset:windows-1252': 0.65; '20,': 0.65; 'physical': 0.69; 'have?': 0.84; 'subject:available': 0.96 |
| 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:to :content-type:content-transfer-encoding; bh=fPtxnEZ9sgq0Cjfy35KR9u+7ZJ/zk/1wTXdAAU3lRQE=; b=NHrBLJ49et6MbJl5BNpK2OzYN/BH5mxAbjpqKP+gKFFuhdDFeD6qVAPYwu8F/O7jZo uQTjvg+0L4m5bNaRbyAQaCUWL7BdENWT3Gs7vjYBov7LESgn03IdIBJOAQwRc0ZPpTpx wV7MZbBb2H0mSLKYq9MA3qbkJkOBGsdIHpLx0lu6RghV37RqB4b0HOvTN2E4QqeHwnC1 aJ7kudYWkZxEqOr1CFgyt8Hn5y0BDOqbuSkucO/Fcx0kyTROLAkE4uvR9p7RioHOJVs9 Wk7scPv0eMQPmDLb+/DbKUasdtUlVHVtbUKn3mko96SONiV37VYWuWn0krc6QfGCw5j+ ErLw== |
| MIME-Version | 1.0 |
| In-Reply-To | <76D03718A3233B4C8CC236C169B535B5A23E063E45@AUSP01VMBX08.collaborationhost.net> |
| References | <76D03718A3233B4C8CC236C169B535B5A23E063E45@AUSP01VMBX08.collaborationhost.net> |
| Date | Sat, 20 Oct 2012 06:18:56 +1100 |
| Subject | Re: Python does not take up available physical memory |
| From | Chris Angelico <rosuav@gmail.com> |
| To | python-list@python.org |
| Content-Type | text/plain; charset=windows-1252 |
| Content-Transfer-Encoding | quoted-printable |
| 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.2528.1350674338.27098.python-list@python.org> (permalink) |
| Lines | 27 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1350674338 news.xs4all.nl 6917 [2001:888:2000:d::a6]:53098 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:31761 |
Show key headers only | View raw
On Sat, Oct 20, 2012 at 4:08 AM, Pradipto Banerjee
<pradipto.banerjee@adainvestments.com> wrote:
> I am trying to read a file into memory. The size of the file is around 1 GB.
> I have a 3GB memory PC and the Windows Task Manager shows 2.3 GB available
> physical memory when I was trying to read the file. I tried to read the file
> as follows:
>
>
>
>>>> fdata = open(filename, ‘r’).read()
Is this Python 2 or Python 3? Just throwing a random possibility out
there, could it be that reading it in and converting it to Unicode
text requires more memory than you have?
My recommendation: Unless you actually need to search the whole file
as a single string, iterate over the file instead:
for line in open(filename):
# do something with line
Your loop will execute once for each line in the file.
ChrisA
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: Python does not take up available physical memory Chris Angelico <rosuav@gmail.com> - 2012-10-20 06:18 +1100
csiph-web