summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorTodd Gamblin <tgamblin@llnl.gov>2016-03-26 00:56:19 -0700
committerTodd Gamblin <tgamblin@llnl.gov>2016-03-27 11:30:09 -0700
commitb0b882cbb3d903a85413acb0439a02d6ac9e26fc (patch)
treee8bb82ac3b2ee94f4722db08208fb92d7df0e13b /lib
parent42ec82237921b87316548ca3ce113e59acd2c21d (diff)
downloadspack-b0b882cbb3d903a85413acb0439a02d6ac9e26fc.tar.gz
spack-b0b882cbb3d903a85413acb0439a02d6ac9e26fc.tar.bz2
spack-b0b882cbb3d903a85413acb0439a02d6ac9e26fc.tar.xz
spack-b0b882cbb3d903a85413acb0439a02d6ac9e26fc.zip
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)`
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/llnl/util/lang.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/spack/llnl/util/lang.py b/lib/spack/llnl/util/lang.py
index 13d301f84e..3b4e2c8352 100644
--- a/lib/spack/llnl/util/lang.py
+++ b/lib/spack/llnl/util/lang.py
@@ -117,7 +117,8 @@ def caller_locals():
scope. Yes, this is some black magic, and yes it's useful
for implementing things like depends_on and provides.
"""
- stack = inspect.stack()
+ # Passing zero here skips line context for speed.
+ stack = inspect.stack(0)
try:
return stack[2][0].f_locals
finally:
@@ -128,7 +129,8 @@ def get_calling_module_name():
"""Make sure that the caller is a class definition, and return the
enclosing module's name.
"""
- stack = inspect.stack()
+ # Passing zero here skips line context for speed.
+ stack = inspect.stack(0)
try:
# Make sure locals contain __module__
caller_locals = stack[2][0].f_locals