PLY: avoid list to dict conversion

Use dictionary comprehension instead of converting list comprehension
to dictionary. Gives around 2.5% speedup, and will probably scale in
favor of dict comprehension.
This commit is contained in:
Mikhail Rachinskiy 2020-07-15 05:32:14 +04:00
parent 054ee2f417
commit cb3f8ec4b1
1 changed files with 6 additions and 1 deletions

View File

@ -110,7 +110,12 @@ class ObjectSpec:
self.specs = []
def load(self, format, stream):
return dict([(i.name, [i.load(format, stream) for j in range(i.count)]) for i in self.specs])
return {
i.name: [
i.load(format, stream) for j in range(i.count)
]
for i in self.specs
}
# Longhand for above LC
"""