Replace list comprehension with generator. (#5526)

# Replace list comprehension with generator.

Since these strings can be fairly long, it's best to not construct
unnecessary temporary list just to pass it to `join`. Generators produce
items one-by-one and even though they are slightly more expensive than
lists in terms of CPU they are much more memory-friendly and slightly
more readable.
searx_updates
Taras Tsugrii 12 months ago committed by GitHub
parent 4c8aad0d1b
commit 359fb8fa3a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -35,10 +35,8 @@ class CombiningOutputParser(BaseOutputParser):
initial = f"For your first output: {self.parsers[0].get_format_instructions()}"
subsequent = "\n".join(
[
f"Complete that output fully. Then produce another output, separated by two newline characters: {p.get_format_instructions()}" # noqa: E501
for p in self.parsers[1:]
]
f"Complete that output fully. Then produce another output, separated by two newline characters: {p.get_format_instructions()}" # noqa: E501
for p in self.parsers[1:]
)
return f"{initial}\n{subsequent}"

Loading…
Cancel
Save