Mercurial > p > roundup > code
changeset 8542:a4f017ae1477
perf: dereference methods before using in loop
I have a few comprehensions where I use self.FsValue and
self.json_dict.
Assign self.X to a variable and use the variable in the
comprehension. This may provide a little speedup since the lookup is
done once.
| author | John Rouillard <rouilj@ieee.org> |
|---|---|
| date | Tue, 24 Mar 2026 16:56:38 -0400 |
| parents | 7a7f6ee0a09e |
| children | 1ffa1f42e1da |
| files | roundup/rest.py |
| diffstat | 1 files changed, 5 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/roundup/rest.py Mon Mar 23 22:22:24 2026 -0400 +++ b/roundup/rest.py Tue Mar 24 16:56:38 2026 -0400 @@ -2761,12 +2761,14 @@ self.value = None return + fsvalue = self.FsValue try: self.json_dict = json.loads(json_string, parse_constant=raise_error_on_constant) - self.value = [self.FsValue(index, self.json_dict[index]) - for index in self.json_dict if - self.json_dict[index] is not None] + json_dict = self.json_dict + self.value = [fsvalue(index, json_dict[index]) + for index in json_dict if + json_dict[index] is not None] except (JSONDecodeError, ValueError) as e: raise ValueError(e.args[0] + ". JSON is: " + json_string)
