|
From: Derrick 'd. H. <dm...@dm...> - 2002-06-25 01:54:12
|
I tried using python-ldap today (1.9.999.pre04-1, python 2.1.3-3), but
it is way too inefficient. A simple search that results in 2 entries
returned takes 30 seconds. Watching with top shows nearly 100% CPU
usage for the 30 seconds, on an otherwise idle Athlon XP 1800+.
OpenLDAP (2.0) is running on that same machine, however using
ldapsearch or exim yields immediate results. =20
$ cat maillist.py
#!/usr/bin/python2.1
import sys
import ldap
INIT =3D "ldap://localhost/"
BASE =3D "ou=3DPeople,o=3DInternational Teams"
TIMEOUT =3D 40
listname =3D sys.argv[1]
ldapconn =3D ldap.initialize( INIT )
results =3D ldapconn.search_st( BASE , ldap.SCOPE_ONELEVEL ,
'(mailGroupLocalPart=3D%s)' % listname ,
attrlist =3D ("uid",) , timeout =3D TIMEOUT
)=20
names =3D [ attrs['uid'][0] for dn , attrs in results]
print ' , '.join( names )
$ time ./maillist.py AITP
dann , derrick
real 0m36.555s
user 0m32.990s
sys 0m3.490s
$ time ldapsearch -x -h localhost -b "ou=3DPeople,o=3DInternational Teams"
-s one "(mailGroupLocalPart=3Daitp)" "uid" | grep uid:=20
uid: dann
uid: derrick
real 0m0.033s
user 0m0.000s
sys 0m0.010s
I think this rather clearly points to python-ldap as the culprit. I
need to do some integration of LDAP and some web-based programs, and
would like to work with python, but this sort of performance hit just
won't be usable. I'm willing to help with the code, if you point me
to the interesting parts (and help me learn the C API of python and
openldap as I go).
I did a quick glance over the archives and read this thread :
http://www.geocrawler.com/lists/3/SourceForge/1568/0/8932688/
-D
--=20
How great is the love the Father has lavished on us,
that we should be called children of God!
1 John 3:1=20
=20
http://dman.ddts.net/~dman/
|