Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!newsfeed.xs4all.nl!newsfeed4.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.019 X-Spam-Evidence: '*H*': 0.96; '*S*': 0.00; 'iterate': 0.09; 'subject:()': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; 'generators.': 0.16; 'subject:Reading': 0.16; 'subject:URL': 0.16; 'subject:versus': 0.16; 'wrote:': 0.18; 'memory': 0.22; 'email addr:gmail.com>': 0.22; 'cc:addr:python.org': 0.22; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; '>': 0.26; 'suggested': 0.26; 'header:In-Reply-To:1': 0.27; "doesn't": 0.30; 'message- id:@mail.gmail.com': 0.30; "i'm": 0.30; 'subject:from': 0.34; 'skip:u 20': 0.35; 'received:google.com': 0.35; 'two': 0.37; 'skip:[ 10': 0.38; 'sure': 0.39; 'how': 0.40; 'different': 0.65; 'to:addr:gmail.com': 0.65; 'between': 0.67; '2013': 0.98 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 :cc:content-type; bh=/7UsZzXiYAYNzJ3VNI+VS3uC1EqHn/gW/j7m49ba7fU=; b=uIPJw/hfx4GiuTjvSGTqw+xeOA+ZxtRdXik54zeaqUJZKwKcpvFr/fKiHjlrIrkOyh Fzr0G9Nk+JtEItRTu0smkmOYOo72VJm8TfssaSJnTGo/MG6UrlzplWwP+0O/y91zuthV qVEZhrrS1LV7495IpJqF3QevlmwFNGizV2xsTwhmioTeJM2Uj8jJXC7A4Jzs3dtED3Qa 2w3yGg9n/jNq9nzRemDOMZzgnN1LvLpjyzupwnl3VjCX4vg9R8stf6sVzJuhuppvfANc bJN9nJ9Pp3SzpkrK9zdrGjwsCR4fze1/H1l9NI01oq5js8bwtY4R2n14BuOrINbMvNpN NVGQ== MIME-Version: 1.0 X-Received: by 10.49.120.198 with SMTP id le6mr4141278qeb.59.1369697815044; Mon, 27 May 2013 16:36:55 -0700 (PDT) In-Reply-To: References: <10be5c62-4c58-4b4f-b00a-82d85ee4ef8e@googlegroups.com> Date: Tue, 28 May 2013 00:36:54 +0100 Subject: Re: Reading *.json from URL - json.loads() versus urllib.urlopen.readlines() From: =?ISO-8859-1?Q?F=E1bio_Santos?= To: Bryan Britten Content-Type: multipart/alternative; boundary=047d7bdca9beb7465604ddbb9f86 Cc: python-list@python.org 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: 30 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1369697823 news.xs4all.nl 15863 [2001:888:2000:d::a6]:50199 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:46231 --047d7bdca9beb7465604ddbb9f86 Content-Type: text/plain; charset=ISO-8859-1 On 27 May 2013 22:36, "Bryan Britten" wrote: > > Try to not sigh audibly as I ask what I'm sure are two asinine questions. > > 1) How is this approach different from twtrDict = [json.loads(line) for line in urllib.urlopen(urlStr)]? > The suggested approach made use of generators. Just because you can iterate over something, that doesn't mean it is all in memory ;) Check out the difference between range() and xrange() in python 2 --047d7bdca9beb7465604ddbb9f86 Content-Type: text/html; charset=ISO-8859-1


On 27 May 2013 22:36, "Bryan Britten" <britten.bryan@gmail.com> wrote:
>
> Try to not sigh audibly as I ask what I'm sure are two asinine questions.
>
> 1) How is this approach different from twtrDict = [json.loads(line) for line in urllib.urlopen(urlStr)]?
>

The suggested approach made use of generators. Just because you can iterate over something, that doesn't mean it is all in memory ;)

Check out the difference between range() and xrange() in python 2

--047d7bdca9beb7465604ddbb9f86--