Recently I have noticed my Django project starts up much slower comparing to a month ago, typically 5~6 seconds slower, I don't remember updating any packages and also validated on Ubuntu server that it doesn't suffer the same problem, so my only guess is that due to my MacOS upgrade.
So I ran python profiler:
python -m cProfile -o /tmp/result manage.py
Then inspected the result using snakeviz
:
snakeviz /tmp/result
This indicated the slowness is in the ldap package by hovering __init__.py:5
:
Then I went into the __init__.py
and discovered that the following line took the most of the time:
LIBLDAP_API_INFO = _ldap.get_option(_ldap.OPT_API_INFO)
Further digging into get_option
it goes into source code of _ldap.cpython-36m-darwin.so
def get_option(*args, **kwargs): # real signature unknown
pass
Just wondering if anyone is having similar issues and how to fix it?