You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Maybe this can be deferred a little bit into the case where it's actually needed.
Python 3.14 has lazy import - that might be nice to use in the future ;-)
pyasn1 adds another significant chunk because LDAP controls and extended operations (also DDS) are imported - result4() requires the control decoding methods.
pprint is only in if __debug__: calls and could be lazy-imported.
But I don't want to hijack the original problem. We rewrote one component in rust due to this.
Yes, reorganising the imports might make sense. Still 5s sounds like an issue somewhere (not quite waiting for a timeout though) rather than something like ~300ms which is more along the lines I was thinking being slow? We can move to that but I'd like @variable to check that's also what they're seeing and not e.g. some poll/select calls dominating the trace.
Activity
variable commentedon Aug 23, 2022
I did a more simple python file just to
import _ldapand profiled it and got thismistotebe commentedon Aug 28, 2026
Hi, is this still happening for you? If so, can you provide strace output as well?
spaceone commentedon Sep 1, 2026
btw: the regular import on Debian is also not as fast as wished. It takes 300ms on some test virtual machines.
mistotebe commentedon Sep 2, 2026
Same, strace might show where the time went (
-ttand/or-Tto include timing info)spaceone commentedon Sep 10, 2026
strace reveals:
siteinitializationldapstarts, stdlib helpers_ldap.so+ native LDAP/SASL/TLS/Kerberos stackldap.functions,ldapobject, schema + huge stdlib dependency treepyasn1We have some SASL client modules which are loaded:
python3 -X importtime -c 'import ldap'is also helpful for the pure python import timings:ldap.functionsldap.ldapobjectldap.schemaldap.schema.subentryurllib.request_ldapldap.controlsldap.extopldap.extop.ddspyasn1_modules.rfc2251tracebackpprintldap.schema.subentryimportsurllib.request, which is a particularly expensive dependency tree:Maybe this can be deferred a little bit into the case where it's actually needed.
Python 3.14 has
lazy import- that might be nice to use in the future ;-)pyasn1adds another significant chunk because LDAP controls and extended operations (also DDS) are imported -result4()requires the control decoding methods.pprintis only inif __debug__:calls and could be lazy-imported.But I don't want to hijack the original problem. We rewrote one component in rust due to this.
mistotebe commentedon Sep 24, 2026
Yes, reorganising the imports might make sense. Still 5s sounds like an issue somewhere (not quite waiting for a timeout though) rather than something like ~300ms which is more along the lines I was thinking being slow? We can move to that but I'd like @variable to check that's also what they're seeing and not e.g. some poll/select calls dominating the trace.