Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Stephen Hansen Newsgroups: comp.lang.python Subject: Re: Fastest way to retrieve and write html contents to file Date: Sun, 01 May 2016 22:15:36 -0700 Lines: 16 Message-ID: References: <85vb2xgj2i.fsf@benfinney.id.au> <1462166136.1167243.595273897.291B0865@webmail.messagingengine.com> Mime-Version: 1.0 Content-Type: text/plain Content-Transfer-Encoding: 7bit X-Trace: news.uni-berlin.de 0vvirzUzMj/F0WeM1MuMRQsphXWmnJFgCbvx4gXD+Q7Q== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.004 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'subject:file': 0.07; 'versions.': 0.07; 'received:internal': 0.09; '10:00': 0.16; '175': 0.16; 'dfs': 0.16; 'how,': 0.16; 'message- id:@webmail.messagingengine.com': 0.16; 'received:10.202': 0.16; 'received:10.202.2': 0.16; 'received:66.111': 0.16; 'received:66.111.4': 0.16; 'received:io': 0.16; 'received:messagingengine.com': 0.16; 'received:psf.io': 0.16; 'wrote:': 0.16; 'stephen': 0.22; 'tried': 0.24; 'import': 0.24; 'header:In-Reply-To:1': 0.24; 'testing': 0.25; 'skip:" 20': 0.26; 'skip:u 20': 0.28; 'this?': 0.34; 'to:addr:python-list': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'received:10': 0.37; 'received:66': 0.38; 'several': 0.38; 'test': 0.39; 'to:addr:python.org': 0.40; 'header:Message-Id:1': 0.61; 'per': 0.62; 'times': 0.63; 'subject:write': 0.84 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=ixokai.io; h= content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-sasl-enc :x-sasl-enc; s=mesmtp; bh=8a24Kx8tG9/xKmQJ7o+QlCvYTOg=; b=onInnH ievM30reMBL35AbFczC3N/8ldvzVLl4xY4AbG92XtNWXGAL+0FSsQNs6elTHkM6b TtXoMQchbf4vnRkX92ITDcVq8K4UposGM4UasROxgso0Tc+Zm1gzV70spC/VCRQA NunQarTCXw4bG07i3o3DzysB87vlkgAwb0HvM= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-sasl-enc:x-sasl-enc; s=smtpout; bh=8a24Kx8tG9/xKmQ J7o+QlCvYTOg=; b=a0LPSr4Oc7eAw2Us/616STUJqOrkO5rVHJeA+SBmEcFtQSS ceXXpTElDieXT867C9h4i/DwgNVP2LJZoJwi+LAJJt6Lbirl52xUMpl73y6+iKGU 9K5DVPkjsQqBxvvyVEAcEu14mIwEv/FRz172ME0bOUkKCD6vQCwORr+kMTJc= X-Sasl-Enc: FmeVGaYykhP1EZ2Ar/yN9J+y/jDvyu7WrqfQCEfLZpcJ 1462166136 X-Mailer: MessagingEngine.com Webmail Interface - ajax-491eb5a4 In-Reply-To: X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Mailman-Original-Message-ID: <1462166136.1167243.595273897.291B0865@webmail.messagingengine.com> X-Mailman-Original-References: <85vb2xgj2i.fsf@benfinney.id.au> Xref: csiph.com comp.lang.python:107981 On Sun, May 1, 2016, at 10:00 PM, DFS wrote: > I tried the 10-loop test several times with all versions. Also how, _exactly_, are you testing this? C:\Python27>python -m timeit "filename='C:\\test.txt'; webpage='http://econpy.pythonanywhere.com/ex/001.html'; import urllib2; r = urllib2.urlopen(webpage); f = open(filename, 'w'); f.write(r.read()); f.close();" 10 loops, best of 3: 175 msec per loop That's a whole lot less the 0.88secs. -- Stephen Hansen m e @ i x o k a i . i o