Skip to content

Commit a2c4c8c

Browse files
committed
Faster iteration in ModuleLoadEnvironment
1 parent 2aa7085 commit a2c4c8c

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

easybuild/tools/modules.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -294,8 +294,7 @@ def items(self):
294294
- key = attribute name
295295
- value = its "contents" attribute
296296
"""
297-
for attr in self.__dict__:
298-
yield attr, getattr(self, attr)
297+
return self.__dict__.items()
299298

300299
def update(self, new_env):
301300
"""Update contents of environment from given dictionary"""
@@ -318,10 +317,7 @@ def environ(self):
318317
Return dict with mapping of ModuleEnvironmentVariables names with their contents
319318
Equivalent in shape to os.environ
320319
"""
321-
mapping = {}
322-
for envar_name, envar_contents in self.items():
323-
mapping.update({envar_name: str(envar_contents)})
324-
return mapping
320+
return {envar_name: str(envar_contents) for envar_name, envar_contents in self.items()}
325321

326322

327323
class ModulesTool(object):

0 commit comments

Comments
 (0)