Reading *.json from URL - json.loads() versus urllib.urlopen.readlines()

Fábio Santos fabiosantosart at gmail.com
Mon May 27 19:36:54 EDT 2013


On 27 May 2013 22:36, "Bryan Britten" <britten.bryan at 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20130528/7e9b4402/attachment.html>


More information about the Python-list mailing list