[Bf-extensions-cvs] [cb3f8ec4] master: 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.

Mikhail Rachinskiy noreply at git.blender.org
Wed Jul 15 03:41:17 CEST 2020


Commit: cb3f8ec4b1c46e3130c9fb8f20cc8e892442c941
Author: Mikhail Rachinskiy
Date:   Wed Jul 15 05:32:14 2020 +0400
Branches: master
https://developer.blender.org/rBAcb3f8ec4b1c46e3130c9fb8f20cc8e892442c941

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.

===================================================================

M	io_mesh_ply/import_ply.py

===================================================================

diff --git a/io_mesh_ply/import_ply.py b/io_mesh_ply/import_ply.py
index 2bf91442..915368d7 100644
--- a/io_mesh_ply/import_ply.py
+++ b/io_mesh_ply/import_ply.py
@@ -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
         """



More information about the Bf-extensions-cvs mailing list