use static sets rather then tuples, python optimizes this case.
authorCampbell Barton <ideasman42@gmail.com>
Mon, 8 Aug 2011 05:21:37 +0000 (05:21 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Mon, 8 Aug 2011 05:21:37 +0000 (05:21 +0000)
minor change to lightmap unpack collecting unique meshes.

12 files changed:
release/scripts/modules/bpy_extras/io_utils.py
release/scripts/modules/bpy_extras/mesh_utils.py
release/scripts/modules/bpyml.py
release/scripts/modules/bpyml_ui.py
release/scripts/modules/rna_info.py
release/scripts/startup/bl_operators/uvcalc_lightmap.py
release/scripts/startup/bl_operators/wm.py
release/scripts/startup/bl_ui/properties_particle.py
release/scripts/templates/operator_modal.py
release/scripts/templates/operator_modal_draw.py
release/scripts/templates/operator_modal_view3d.py
source/tests/bl_run_operators.py

index 45664384efaa4372ccc3ba66a93fd67ab41153ee..bb4e95c051f0422cbf8cd22d1f4da566db140841 100644 (file)
@@ -379,7 +379,7 @@ def path_reference(filepath,
     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'
index f94006741387ce0b2eeca43629fbc555b414401c..c965169ff04cdb267a43dd2abff40d21a1aaa410 100644 (file)
@@ -294,7 +294,7 @@ def ngon_tesselate(from_data, indices, fix_loops=True):
         '''
         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 @@ def ngon_tesselate(from_data, indices, fix_loops=True):
         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:
index fdf5172a0b3597418369c0a31dcc80a396ed1d0e..42d2bf94fbaa99585208db55ba70ecd78215519c 100644 (file)
@@ -120,7 +120,7 @@ def fromxml(data):
         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
 
index 5df04b8bf34784c410cb0ce197bc0b69a2996ffe..f4b6de23dbb2cf93ce9b68fe8137bfc7fa3e2ff4 100644 (file)
@@ -40,13 +40,13 @@ def _parse_rna(prop, value):
     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)
index 93a344f4b09f97570feed6f58aec66a5e0344742..943f86adecbeea2a001264dd8d075b6df2953b4e 100644 (file)
@@ -148,7 +148,7 @@ class InfoStructRNA:
         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 @@ class InfoStructRNA:
         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 @@ class InfoPropertyRNA:
             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 @@ def BuildRNAInfo():
             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))
 
index 9ae0cd0ddf961a048659685482f27954cafd7b87..2f1acf0a5dc71d72450d5dd9bbc24ee2ca26f568 100644 (file)
@@ -520,7 +520,7 @@ def unwrap(operator, context, **kwargs):
         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.")
index af33e45668c19933b84a5e1f0a50cc2172f44314..f9327aa6c4007ca503fe558a8f5cf713283c66de 100644 (file)
@@ -586,7 +586,7 @@ class WM_OT_context_modal_mouse(bpy.types.Operator):
             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 @@ class WM_OT_properties_edit(bpy.types.Operator):
 
         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)
index 4c92296dacdc451a7ea8e1b0e55b089d7a5144f2..2870aab75efa9d8050e6db012e5dc1e673673827 100644 (file)
@@ -462,7 +462,7 @@ class PARTICLE_PT_physics(ParticleButtonsPanel, bpy.types.Panel):
             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 @@ class PARTICLE_PT_render(ParticleButtonsPanel, bpy.types.Panel):
                 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)
index 78dbd4c6b433d5e47239f75e650d5668f58df896..ed98c2cf50ebb51cc43447b41e56c1f7fb884c6a 100644 (file)
@@ -18,7 +18,7 @@ class ModalOperator(bpy.types.Operator):
         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'}
 
index e7a1f6e4ffeafc573437d3f9de263610bd504f76..b3d525a59bf08596ad17292e6e31901cc82e5c8f 100644 (file)
@@ -45,7 +45,7 @@ class ModalDrawOperator(bpy.types.Operator):
             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'}
 
index c494f121017e2660c4acd779eccdbaf5aa2c6bbb..925449835ca651d4b5dc76ad1b2205c86f7de755 100644 (file)
@@ -29,7 +29,7 @@ class ViewOperator(bpy.types.Operator):
             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'}
index 668b4e692284242f0681f30ef5d8de21606b0b12..b64055df252b9b6cb1e3cceb99b0e290f348c38c 100644 (file)
@@ -70,7 +70,7 @@ def run_ops(operators, setup_func=None):
 
             setup_func()
 
-            for mode in ('EXEC_DEFAULT', 'INVOKE_DEFAULT'):
+            for mode in {'EXEC_DEFAULT', 'INVOKE_DEFAULT'}:
                 try:
                     op(mode)
                 except: