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
By default, if scope is not provided include() pulls the scope off the stack frame above the include() frame. It does this by calling inspect.stack(). This call does an enormous amount of unnecessary work. It builds frame info objects for the entire stack.
I noticed this on a production system that has some management commands that have shell tab completions. This means each time I hit tab, the entire Django stack is loaded. It was noticeably slow (~1.5 seconds). Profiling suggested 1/3 of that time was spent in inspect.stack(). This production system had roughly 20 calls to include() - to build the settings.
I removed all of that overhead by changing this line:
scope=scopeorinspect.stack()[1][0].f_globals
To this:
scope=scopeorsys._getframe(1).f_globals
I'll submit a PR.
The text was updated successfully, but these errors were encountered:
bckohan
added a commit
to bckohan/django-split-settings
that referenced
this issue
Apr 5, 2024
By default, if scope is not provided include() pulls the scope off the stack frame above the include() frame. It does this by calling inspect.stack(). This call does an enormous amount of unnecessary work. It builds frame info objects for the entire stack.
I noticed this on a production system that has some management commands that have shell tab completions. This means each time I hit tab, the entire Django stack is loaded. It was noticeably slow (~1.5 seconds). Profiling suggested 1/3 of that time was spent in inspect.stack(). This production system had roughly 20 calls to include() - to build the settings.
I removed all of that overhead by changing this line:
To this:
I'll submit a PR.
The text was updated successfully, but these errors were encountered: