Mercurial > hgrepos > Python > libs > ConfigMix
comparison configmix/config.py @ 497:8e516f17cf95
Optimize .substitute_variables_in_obj: use dict.items() to avoid one dict lookup
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Fri, 17 Dec 2021 23:53:38 +0100 |
| parents | 3f0c932588fc |
| children | f46932e8a84c |
comparison
equal
deleted
inserted
replaced
| 496:36ab39e3de53 | 497:8e516f17cf95 |
|---|---|
| 636 if issubclass(ty, _TEXTTYPE): | 636 if issubclass(ty, _TEXTTYPE): |
| 637 # a string - really replace the value | 637 # a string - really replace the value |
| 638 return self.expand_variable(obj) | 638 return self.expand_variable(obj) |
| 639 elif issubclass(ty, dict): | 639 elif issubclass(ty, dict): |
| 640 newdict = ty() | 640 newdict = ty() |
| 641 for k in obj: | 641 for k, v in obj.items(): |
| 642 newdict[k] = self.substitute_variables_in_obj(obj[k]) | 642 newdict[k] = self.substitute_variables_in_obj(v) |
| 643 return newdict | 643 return newdict |
| 644 elif issubclass(ty, list): | 644 elif issubclass(ty, list): |
| 645 return [self.substitute_variables_in_obj(i) for i in obj] | 645 return [self.substitute_variables_in_obj(i) for i in obj] |
| 646 elif issubclass(ty, tuple): | 646 elif issubclass(ty, tuple): |
| 647 tmp = [self.substitute_variables_in_obj(i) for i in obj] | 647 tmp = [self.substitute_variables_in_obj(i) for i in obj] |
