[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [39170] trunk/blender: use static sets rather then tuples, python optimizes this case.

Campbell Barton ideasman42 at gmail.com
Mon Aug 8 07:21:38 CEST 2011


Revision: 39170
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=39170
Author:   campbellbarton
Date:     2011-08-08 05:21:37 +0000 (Mon, 08 Aug 2011)
Log Message:
-----------
use static sets rather then tuples, python optimizes this case.
minor change to lightmap unpack collecting unique meshes.

Modified Paths:
--------------
    trunk/blender/release/scripts/modules/bpy_extras/io_utils.py
    trunk/blender/release/scripts/modules/bpy_extras/mesh_utils.py
    trunk/blender/release/scripts/modules/bpyml.py
    trunk/blender/release/scripts/modules/bpyml_ui.py
    trunk/blender/release/scripts/modules/rna_info.py
    trunk/blender/release/scripts/startup/bl_operators/uvcalc_lightmap.py
    trunk/blender/release/scripts/startup/bl_operators/wm.py
    trunk/blender/release/scripts/startup/bl_ui/properties_particle.py
    trunk/blender/release/scripts/templates/operator_modal.py
    trunk/blender/release/scripts/templates/operator_modal_draw.py
    trunk/blender/release/scripts/templates/operator_modal_view3d.py
    trunk/blender/source/tests/bl_run_operators.py

Modified: trunk/blender/release/scripts/modules/bpy_extras/io_utils.py
===================================================================
--- trunk/blender/release/scripts/modules/bpy_extras/io_utils.py	2011-08-08 04:28:30 UTC (rev 39169)
+++ trunk/blender/release/scripts/modules/bpy_extras/io_utils.py	2011-08-08 05:21:37 UTC (rev 39170)
@@ -379,7 +379,7 @@
     is_relative = filepath.startswith("//")
     filepath_abs = os.path.normpath(bpy.path.abspath(filepath, base_src))
 
-    if mode in ('ABSOLUTE', 'RELATIVE', 'STRIP'):
+    if mode in {'ABSOLUTE', 'RELATIVE', 'STRIP'}:
         pass
     elif mode == 'MATCH':
         mode = 'RELATIVE' if is_relative else 'ABSOLUTE'

Modified: trunk/blender/release/scripts/modules/bpy_extras/mesh_utils.py
===================================================================
--- trunk/blender/release/scripts/modules/bpy_extras/mesh_utils.py	2011-08-08 04:28:30 UTC (rev 39169)
+++ trunk/blender/release/scripts/modules/bpy_extras/mesh_utils.py	2011-08-08 05:21:37 UTC (rev 39170)
@@ -294,7 +294,7 @@
         '''
         Normal single concave loop filling
         '''
-        if type(from_data) in (tuple, list):
+        if type(from_data) in {tuple, list}:
             verts = [Vector(from_data[i]) for ii, i in enumerate(indices)]
         else:
             verts = [from_data.vertices[i].co for ii, i in enumerate(indices)]
@@ -312,7 +312,7 @@
         used twice. This is used by lightwave LWO files a lot
         '''
 
-        if type(from_data) in (tuple, list):
+        if type(from_data) in {tuple, list}:
             verts = [vert_treplet(Vector(from_data[i]), ii)
                      for ii, i in enumerate(indices)]
         else:

Modified: trunk/blender/release/scripts/modules/bpyml.py
===================================================================
--- trunk/blender/release/scripts/modules/bpyml.py	2011-08-08 04:28:30 UTC (rev 39169)
+++ trunk/blender/release/scripts/modules/bpyml.py	2011-08-08 05:21:37 UTC (rev 39170)
@@ -120,7 +120,7 @@
         py_item = (xml_node.tagName, _fromxml_kwargs(xml_node), [])
         #_fromxml_iter(py_item, xml_node.childNodes)
         for xml_node_child in xml_node.childNodes:
-            if xml_node_child.nodeType not in (xml_node_child.TEXT_NODE, xml_node_child.COMMENT_NODE):
+            if xml_node_child.nodeType not in {xml_node_child.TEXT_NODE, xml_node_child.COMMENT_NODE}:
                 py_item[CHILDREN].append(_fromxml(xml_node_child))
         return py_item
 

Modified: trunk/blender/release/scripts/modules/bpyml_ui.py
===================================================================
--- trunk/blender/release/scripts/modules/bpyml_ui.py	2011-08-08 04:28:30 UTC (rev 39169)
+++ trunk/blender/release/scripts/modules/bpyml_ui.py	2011-08-08 05:21:37 UTC (rev 39170)
@@ -40,13 +40,13 @@
     elif prop.type == 'INT':
         value = int(value)
     elif prop.type == 'BOOLEAN':
-        if value in (True, False):
+        if value in {True, False}:
             pass
         else:
-            if value not in ("True", "False"):
+            if value not in {"True", "False"}:
                 raise Exception("invalid bool value: %s" % value)
             value = bool(value == "True")
-    elif prop.type in ('STRING', 'ENUM'):
+    elif prop.type in {'STRING', 'ENUM'}:
         pass
     elif prop.type == 'POINTER':
         value = eval("_bpy." + value)

Modified: trunk/blender/release/scripts/modules/rna_info.py
===================================================================
--- trunk/blender/release/scripts/modules/rna_info.py	2011-08-08 04:28:30 UTC (rev 39169)
+++ trunk/blender/release/scripts/modules/rna_info.py	2011-08-08 05:21:37 UTC (rev 39170)
@@ -148,7 +148,7 @@
         import types
         functions = []
         for identifier, attr in self._get_py_visible_attrs():
-            if type(attr) in (types.FunctionType, types.MethodType):
+            if type(attr) in {types.FunctionType, types.MethodType}:
                 functions.append((identifier, attr))
         return functions
 
@@ -156,7 +156,7 @@
         import types
         functions = []
         for identifier, attr in self._get_py_visible_attrs():
-            if type(attr) in (types.BuiltinMethodType, types.BuiltinFunctionType):
+            if type(attr) in {types.BuiltinMethodType, types.BuiltinFunctionType}:
                 functions.append((identifier, attr))
         return functions
 
@@ -260,7 +260,7 @@
             if self.array_length:
                 type_str += " array of %d items" % (self.array_length)
 
-            if self.type in ("float", "int"):
+            if self.type in {"float", "int"}:
                 type_str += " in [%s, %s]" % (range_str(self.min), range_str(self.max))
             elif self.type == "enum":
                 if self.is_enum_flag:
@@ -595,7 +595,7 @@
             for prop in rna_info.properties:
                 # ERROR CHECK
                 default = prop.default
-                if type(default) in (float, int):
+                if type(default) in {float, int}:
                     if default < prop.min or default > prop.max:
                         print("\t %s.%s, %s not in [%s - %s]" % (rna_info.identifier, prop.identifier, default, prop.min, prop.max))
 

Modified: trunk/blender/release/scripts/startup/bl_operators/uvcalc_lightmap.py
===================================================================
--- trunk/blender/release/scripts/startup/bl_operators/uvcalc_lightmap.py	2011-08-08 04:28:30 UTC (rev 39169)
+++ trunk/blender/release/scripts/startup/bl_operators/uvcalc_lightmap.py	2011-08-08 05:21:37 UTC (rev 39170)
@@ -520,7 +520,7 @@
         if obj and obj.type == 'MESH':
             meshes = [obj.data]
     else:
-        meshes = {me.name: me for obj in context.selected_objects if obj.type == 'MESH' for me in (obj.data,) if not me.library if len(me.faces)}.values()
+        meshes = list({me for obj in context.selected_objects if obj.type == 'MESH' for me in (obj.data,) if me.faces and me.library is None})
 
     if not meshes:
         operator.report({'ERROR'}, "No mesh object.")

Modified: trunk/blender/release/scripts/startup/bl_operators/wm.py
===================================================================
--- trunk/blender/release/scripts/startup/bl_operators/wm.py	2011-08-08 04:28:30 UTC (rev 39169)
+++ trunk/blender/release/scripts/startup/bl_operators/wm.py	2011-08-08 05:21:37 UTC (rev 39170)
@@ -586,7 +586,7 @@
             self._values_clear()
             return {'FINISHED'}
 
-        elif event_type in ('RIGHTMOUSE', 'ESC'):
+        elif event_type in {'RIGHTMOUSE', 'ESC'}:
             self._values_restore()
             return {'FINISHED'}
 
@@ -839,7 +839,7 @@
 
         prop_ui = rna_idprop_ui_prop_get(item, prop)
 
-        if prop_type in (float, int):
+        if prop_type in {float, int}:
 
             prop_ui['soft_min'] = prop_ui['min'] = prop_type(self.min)
             prop_ui['soft_max'] = prop_ui['max'] = prop_type(self.max)

Modified: trunk/blender/release/scripts/startup/bl_ui/properties_particle.py
===================================================================
--- trunk/blender/release/scripts/startup/bl_ui/properties_particle.py	2011-08-08 04:28:30 UTC (rev 39169)
+++ trunk/blender/release/scripts/startup/bl_ui/properties_particle.py	2011-08-08 05:21:37 UTC (rev 39170)
@@ -462,7 +462,7 @@
             col.prop(part, "mass")
             col.prop(part, "use_multiply_size_mass", text="Multiply mass with size")
 
-        if part.physics_type in ('NEWTON', 'FLUID'):
+        if part.physics_type in {'NEWTON', 'FLUID'}:
             split = layout.split()
 
             col = split.column()
@@ -921,7 +921,7 @@
                 col = row.column()
                 col.label(text="")
 
-        if part.render_type in ('OBJECT', 'GROUP') and not part.use_advanced_hair:
+        if part.render_type in {'OBJECT', 'GROUP'} and not part.use_advanced_hair:
             row = layout.row(align=True)
             row.prop(part, "particle_size")
             row.prop(part, "size_random", slider=True)

Modified: trunk/blender/release/scripts/templates/operator_modal.py
===================================================================
--- trunk/blender/release/scripts/templates/operator_modal.py	2011-08-08 04:28:30 UTC (rev 39169)
+++ trunk/blender/release/scripts/templates/operator_modal.py	2011-08-08 05:21:37 UTC (rev 39170)
@@ -18,7 +18,7 @@
         elif event.type == 'LEFTMOUSE':
             return {'FINISHED'}
 
-        elif event.type in ('RIGHTMOUSE', 'ESC'):
+        elif event.type in {'RIGHTMOUSE', 'ESC'}:
             context.object.location.x = self.first_value
             return {'CANCELLED'}
 

Modified: trunk/blender/release/scripts/templates/operator_modal_draw.py
===================================================================
--- trunk/blender/release/scripts/templates/operator_modal_draw.py	2011-08-08 04:28:30 UTC (rev 39169)
+++ trunk/blender/release/scripts/templates/operator_modal_draw.py	2011-08-08 05:21:37 UTC (rev 39170)
@@ -45,7 +45,7 @@
             context.region.callback_remove(self._handle)
             return {'FINISHED'}
 
-        elif event.type in ('RIGHTMOUSE', 'ESC'):
+        elif event.type in {'RIGHTMOUSE', 'ESC'}:
             context.region.callback_remove(self._handle)
             return {'CANCELLED'}
 

Modified: trunk/blender/release/scripts/templates/operator_modal_view3d.py
===================================================================
--- trunk/blender/release/scripts/templates/operator_modal_view3d.py	2011-08-08 04:28:30 UTC (rev 39169)
+++ trunk/blender/release/scripts/templates/operator_modal_view3d.py	2011-08-08 05:21:37 UTC (rev 39170)
@@ -29,7 +29,7 @@
             context.area.header_text_set()
             return {'FINISHED'}
 
-        elif event.type in ('RIGHTMOUSE', 'ESC'):
+        elif event.type in {'RIGHTMOUSE', 'ESC'}:
             rv3d.view_location = self._initial_location
             context.area.header_text_set()
             return {'CANCELLED'}

Modified: trunk/blender/source/tests/bl_run_operators.py
===================================================================
--- trunk/blender/source/tests/bl_run_operators.py	2011-08-08 04:28:30 UTC (rev 39169)
+++ trunk/blender/source/tests/bl_run_operators.py	2011-08-08 05:21:37 UTC (rev 39170)
@@ -70,7 +70,7 @@
 
             setup_func()
 

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list