Speed up directives by skipping debug info in stack traversal.
- `caller_locals()` doesn't need debug info, only frame locals. - `get_calling_module()` doesn't either. - Changed calls to `inspect.stack()` -> `inspect.stack(0)`
This commit is contained in:
parent
42ec822379
commit
b0b882cbb3
@ -117,7 +117,8 @@ def caller_locals():
|
|||||||
scope. Yes, this is some black magic, and yes it's useful
|
scope. Yes, this is some black magic, and yes it's useful
|
||||||
for implementing things like depends_on and provides.
|
for implementing things like depends_on and provides.
|
||||||
"""
|
"""
|
||||||
stack = inspect.stack()
|
# Passing zero here skips line context for speed.
|
||||||
|
stack = inspect.stack(0)
|
||||||
try:
|
try:
|
||||||
return stack[2][0].f_locals
|
return stack[2][0].f_locals
|
||||||
finally:
|
finally:
|
||||||
@ -128,7 +129,8 @@ def get_calling_module_name():
|
|||||||
"""Make sure that the caller is a class definition, and return the
|
"""Make sure that the caller is a class definition, and return the
|
||||||
enclosing module's name.
|
enclosing module's name.
|
||||||
"""
|
"""
|
||||||
stack = inspect.stack()
|
# Passing zero here skips line context for speed.
|
||||||
|
stack = inspect.stack(0)
|
||||||
try:
|
try:
|
||||||
# Make sure locals contain __module__
|
# Make sure locals contain __module__
|
||||||
caller_locals = stack[2][0].f_locals
|
caller_locals = stack[2][0].f_locals
|
||||||
|
Loading…
Reference in New Issue
Block a user