A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2001-May/014831.html below:

[Python-Dev] Comparison speed

[Python-Dev] Comparison speed [Python-Dev] Comparison speedTim Peters tim.one@home.com
Wed, 16 May 2001 04:51:17 -0400
[Barry A. Warsaw]
> ...
> from types import StringType
> import time
> r = range(1000000)
>
> def one(r=r):
>     x = 'hello'
>     t0 = time.time()
>     for i in r:

Random clue:  when you're too lazy to try to subtact out loop overhead (not a
knock, I am too), you may have better luck with

    r = [1] * 1000000

than

    r = range(1000000)

The reason is that the former way gets to keep incref'ing and decref'ing a
single object (as it's repeatedly bound to "i" across iterations), instead of
slobbering all over memory inc'ing and dec'ing a million distinct objects.

there's-as-an-art-to-doing-nothing-quickly-ly y'rs  - tim




RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4