Package: python2.4
Version: 2.4.2-1
Severity: normal

Parsing a file opened by urllib.urlopen() is horribly slow:

$time python2.4 parse.py
[...]
real    0m8.751s
user    0m6.062s
sys     0m2.437s

$cat parse.py
#!/usr/bin/python2.3

import urllib, re, os

reg = '^(\d+)\s+(\S+)\s+(\d+)\s+\d+\s+\d+\s+\d+\s+\d+'
popcon = urllib.urlopen("http://www2.df7cb.de/tmp/by_inst";)
#popcon = os.popen("wget http://www2.df7cb.de/tmp/by_inst -O - -q")
reg1 = re.compile(reg)

while 1:
    line = popcon.readline()
    if not line:
        break
    if not reg1.search(line):
        continue
    (rank, binary, nr) = reg1.search(line).groups()

    if (int(rank) % 10000) == 0:
        print binary

Using os.popen(wget) is much faster:

$time python2.4 parse.py
[...]
real    0m0.794s
user    0m0.585s
sys     0m0.077s


(www2 is the local host, by_inst is http://popcon.debian.org/by_inst)

-- System Information:
Debian Release: testing/unstable
  APT prefers unstable
  APT policy: (500, 'unstable'), (1, 'experimental')
Architecture: i386 (x86_64)
Shell:  /bin/sh linked to /bin/bash
Kernel: Linux 2.6.8-11-amd64-k8
Locale: LANG=de_DE.UTF-8, LC_CTYPE=de_DE.UTF-8 (charmap=UTF-8)

Versions of packages python2.4 depends on:
ii  libc6                         2.3.5-7    GNU C Library: Shared libraries an
ii  libdb4.3                      4.3.29-1   Berkeley v4.3 Database Libraries [
ii  libncurses5                   5.5-1      Shared libraries for terminal hand
ii  libreadline5                  5.0-11     GNU readline and history libraries
ii  libssl0.9.7                   0.9.7g-5   SSL shared libraries
ii  python2.4-minimal             2.4.2-1    A minimal subset of the Python lan

python2.4 recommends no packages.

-- no debconf information

Christoph
-- 
[EMAIL PROTECTED] | http://www.df7cb.de/

Attachment: signature.asc
Description: Digital signature

Reply via email to