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/2003-May/035876.html below:

[Python-Dev] Algoritmic Complexity Attack on Python

[Python-Dev] Algoritmic Complexity Attack on Python [Python-Dev] Algoritmic Complexity Attack on PythonJeremy Hylton jeremy@zope.com
29 May 2003 17:01:19 -0400
Scott,

I just too a minute too look at this.  I downloaded the python-attack
file from your Web site.  I loading all the strings and then inserted
them into a dictionary.  I also generated a list of 10,000 random
strings and inserted them into a dictionary.

The script is below.

The results show that inserting the python-attack strings is about 4
times slower than inserting random strings.

slothrop:~/src/python/dist/src/build> ./python ~/attack.py
~/python-attack 
time 0.0898009538651
size 10000
slothrop:~/src/python/dist/src/build> ./python ~/attack.py
~/simple        
time 0.0229719877243
size 10000

Jeremy

import time

def main(path):
    L = [l.strip() for l in open(path)]

    d = {}
    t0 = time.time()
    for k in L:
        d[k] = 1
    t1 = time.time()
    print "time", t1 - t0
    print "size", len(d)

if __name__ == "__main__":
    import sys
    main(sys.argv[1])





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