Populating a dictionary, fast [SOLVED SOLVED]

Michael Bacarella mbac at gpshopper.com
Thu Nov 15 22:36:17 CET 2007


> On Thu, 15 Nov 2007 15:51:25 -0500, Michael Bacarella wrote:
> 
> > Since some people missed the EUREKA!, here's the executive summary:
> >
> > 	Python2.3: about 45 minutes
> > 	Python2.4: about 45 minutes
> > 	Python2.5: about _30 seconds_
> 
> I'm really happy that upgrading to 2.5 solved the issue for you, but I
> get similar behaviour and I'm running 2.5, so it isn't as simple as
> that.

Maybe some more details about my environment will help.

Our fast Python is 2.5, built from source.  Our slow Python is 2.3,
default installed with the OS, from rpm.

# python
Python 2.5.1 (r251:54863, May 11 2007, 14:17:21) 
[GCC 3.4.4 20050721 (Red Hat 3.4.4-2)] on linux2
Type "help", "copyright", "credits" or "license" for more information.

# which python
/usr/local/bin/python

# ls -la /usr/local/bin/python
-rwxr-xr-x  2 root root 5312572 Nov 12 12:54 /usr/local/bin/python

# md5sum /usr/local/bin/python
5c24e54a6cf5a556e9371325d18bc1fb  /usr/local/bin/python

# ls -la /usr/bin/python*
lrwxrwxrwx  1 root root    9 Nov 12 12:57 /usr/bin/python -> python2
lrwxrwxrwx  1 root root    6 Nov 12 12:57 /usr/bin/python2 -> python2.5
-rwxr-xr-x  1 root root 8344 May  2  2007 /usr/bin/python2.3
lrwxrwxrwx  1 root root   21 Nov 12 12:57 /usr/bin/python2.5 ->
/usr/local/bin/python

# ls -la /usr/local/src/ | grep Python  
drwxr-xr-x  19    1000 1000     4096 Nov 12 12:54 Python-2.5.1
-rw-r--r--   1 root    root  9383651 Nov 12 12:51 Python-2.5.1.tar.bz2

# gcc -v
Reading specs from /usr/lib/gcc/x86_64-redhat-linux/3.4.4/specs
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man
--infodir=/usr/share/info --enable-shared --enable-threads=posix
--disable-checking --with-system-zlib --enable-__cxa_atexit
--disable-libunwind-exceptions --enable-java-awt=gtk
--host=x86_64-redhat-linux
Thread model: posix
gcc version 3.4.4 20050721 (Red Hat 3.4.4-2)

# cat /etc/redhat-release 
CentOS release 4.2 (Final)

# uname -a
Linux xxx 2.6.9-22.ELsmp #1 SMP Sat Oct 8 21:32:36 BST 2005 x86_64 x86_64
x86_64 GNU/Linux

# free
             total       used       free     shared    buffers     cached
Mem:       7390244    6961440     428804          0      15520    2549732
-/+ buffers/cache:    4396188    2994056
Swap:      2096472      10280    2086192

# cat /proc/cpuinfo 
processor       : 0
vendor_id       : AuthenticAMD
cpu family      : 15
model           : 5
model name      : AMD Opteron(tm) Processor 246
stepping        : 10
cpu MHz         : 2009.305
cache size      : 1024 KB
fpu             : yes
fpu_exception   : yes
cpuid level     : 1
wp              : yes
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca
cmov 
pat pse36 clflush mmx fxsr sse sse2 syscall nx mmxext lm 3dnowext 3dnow
bogomips        : 3981.31
TLB size        : 1088 4K pages
clflush size    : 64
cache_alignment : 64
address sizes   : 40 bits physical, 48 bits virtual
power management: ts fid vid ttp

processor       : 1
vendor_id       : AuthenticAMD
cpu family      : 15
model           : 5
model name      : AMD Opteron(tm) Processor 246
stepping        : 10
cpu MHz         : 2009.305
cache size      : 1024 KB
fpu             : yes
fpu_exception   : yes
cpuid level     : 1
wp              : yes
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca
cmov 
pat pse36 clflush mmx fxsr sse sse2 syscall nx mmxext lm 3dnowext 3dnow
bogomips        : 4014.08
TLB size        : 1088 4K pages
clflush size    : 64
cache_alignment : 64
address sizes   : 40 bits physical, 48 bits virtual
power management: ts fid vid ttp


***** information about Python 2.3 *****

# rpm -qi python
Name        : python                       Relocations: (not relocatable)
Version     : 2.3.4                             Vendor: CentOS
Release     : 14.4                          Build Date: Wed 02 May 2007
07:20:29 PM EDT
Install Date: Mon 04 Jun 2007 05:48:29 PM EDT      Build Host: builder6
Group       : Development/Languages         Source RPM:
python-2.3.4-14.4.src.rpm
Size        : 21137194                         License: PSF - see LICENSE
Signature   : DSA/SHA1, Sat 05 May 2007 09:33:49 AM EDT, Key ID
a53d0bab443e1821
URL         : http://www.python.org/
Summary     : An interpreted, interactive, object-oriented programming
language.
Description :
Python is an interpreted, interactive, object-oriented programming
language often compared to Tcl, Perl, Scheme or Java. Python includes
modules, classes, exceptions, very high level dynamic data types and
dynamic typing. Python supports interfaces to many system calls and
libraries, as well as to various windowing systems (X11, Motif, Tk,
Mac and MFC).

Programmers can write new built-in modules for Python in C or C++.
Python can be used as an extension language for applications that need
a programmable interface. This package contains most of the standard
Python modules, as well as modules for interfacing to the Tix widget
set for Tk and RPM.

Note that documentation for Python is provided in the python-docs
package.




More information about the Python-list mailing list