Skip to content

Commit 19382f7

Browse files
committed
A much better speed-up for AutoUnload
1 parent 2a2804e commit 19382f7

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

  • addons/source-python/packages/source-python/core

‎addons/source-python/packages/source-python/core/__init__.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
from contextlib import contextmanager
1515
# Inspect
1616
from inspect import getmodule
17-
from inspect import stack
17+
from inspect import currentframe
1818
# OS
1919
from os import sep
2020
# Path
@@ -103,7 +103,7 @@ def __new__(cls, *args, **kwargs):
103103
self = super().__new__(cls)
104104

105105
# Get the calling module
106-
caller = getmodule(stack(0)[1][0])
106+
caller = getmodule(currentframe().f_back)
107107

108108
# Call class-specific logic for adding the instance.
109109
self._add_instance(caller.__name__)

0 commit comments

Comments
 (0)