use static sets rather then tuples, python optimizes this case.

minor change to lightmap unpack collecting unique meshes.
This commit is contained in:
Campbell Barton
2011-08-08 05:21:37 +00:00
parent 0160901c90
commit 22d2764d50
12 changed files with 20 additions and 20 deletions

View File

@@ -379,7 +379,7 @@ def path_reference(filepath,
is_relative = filepath.startswith("//") is_relative = filepath.startswith("//")
filepath_abs = os.path.normpath(bpy.path.abspath(filepath, base_src)) filepath_abs = os.path.normpath(bpy.path.abspath(filepath, base_src))
if mode in ('ABSOLUTE', 'RELATIVE', 'STRIP'): if mode in {'ABSOLUTE', 'RELATIVE', 'STRIP'}:
pass pass
elif mode == 'MATCH': elif mode == 'MATCH':
mode = 'RELATIVE' if is_relative else 'ABSOLUTE' mode = 'RELATIVE' if is_relative else 'ABSOLUTE'

View File

@@ -294,7 +294,7 @@ def ngon_tesselate(from_data, indices, fix_loops=True):
''' '''
Normal single concave loop filling 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)] verts = [Vector(from_data[i]) for ii, i in enumerate(indices)]
else: else:
verts = [from_data.vertices[i].co for ii, i in enumerate(indices)] 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 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) verts = [vert_treplet(Vector(from_data[i]), ii)
for ii, i in enumerate(indices)] for ii, i in enumerate(indices)]
else: else:

View File

@@ -120,7 +120,7 @@ def fromxml(data):
py_item = (xml_node.tagName, _fromxml_kwargs(xml_node), []) py_item = (xml_node.tagName, _fromxml_kwargs(xml_node), [])
#_fromxml_iter(py_item, xml_node.childNodes) #_fromxml_iter(py_item, xml_node.childNodes)
for xml_node_child in 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)) py_item[CHILDREN].append(_fromxml(xml_node_child))
return py_item return py_item

View File

@@ -40,13 +40,13 @@ def _parse_rna(prop, value):
elif prop.type == 'INT': elif prop.type == 'INT':
value = int(value) value = int(value)
elif prop.type == 'BOOLEAN': elif prop.type == 'BOOLEAN':
if value in (True, False): if value in {True, False}:
pass pass
else: else:
if value not in ("True", "False"): if value not in {"True", "False"}:
raise Exception("invalid bool value: %s" % value) raise Exception("invalid bool value: %s" % value)
value = bool(value == "True") value = bool(value == "True")
elif prop.type in ('STRING', 'ENUM'): elif prop.type in {'STRING', 'ENUM'}:
pass pass
elif prop.type == 'POINTER': elif prop.type == 'POINTER':
value = eval("_bpy." + value) value = eval("_bpy." + value)

View File

@@ -148,7 +148,7 @@ class InfoStructRNA:
import types import types
functions = [] functions = []
for identifier, attr in self._get_py_visible_attrs(): 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)) functions.append((identifier, attr))
return functions return functions
@@ -156,7 +156,7 @@ class InfoStructRNA:
import types import types
functions = [] functions = []
for identifier, attr in self._get_py_visible_attrs(): 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)) functions.append((identifier, attr))
return functions return functions
@@ -260,7 +260,7 @@ class InfoPropertyRNA:
if self.array_length: if self.array_length:
type_str += " array of %d items" % (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)) type_str += " in [%s, %s]" % (range_str(self.min), range_str(self.max))
elif self.type == "enum": elif self.type == "enum":
if self.is_enum_flag: if self.is_enum_flag:
@@ -595,7 +595,7 @@ def BuildRNAInfo():
for prop in rna_info.properties: for prop in rna_info.properties:
# ERROR CHECK # ERROR CHECK
default = prop.default default = prop.default
if type(default) in (float, int): if type(default) in {float, int}:
if default < prop.min or default > prop.max: 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)) print("\t %s.%s, %s not in [%s - %s]" % (rna_info.identifier, prop.identifier, default, prop.min, prop.max))

View File

@@ -520,7 +520,7 @@ def unwrap(operator, context, **kwargs):
if obj and obj.type == 'MESH': if obj and obj.type == 'MESH':
meshes = [obj.data] meshes = [obj.data]
else: 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: if not meshes:
operator.report({'ERROR'}, "No mesh object.") operator.report({'ERROR'}, "No mesh object.")

View File

@@ -586,7 +586,7 @@ class WM_OT_context_modal_mouse(bpy.types.Operator):
self._values_clear() self._values_clear()
return {'FINISHED'} return {'FINISHED'}
elif event_type in ('RIGHTMOUSE', 'ESC'): elif event_type in {'RIGHTMOUSE', 'ESC'}:
self._values_restore() self._values_restore()
return {'FINISHED'} return {'FINISHED'}
@@ -839,7 +839,7 @@ class WM_OT_properties_edit(bpy.types.Operator):
prop_ui = rna_idprop_ui_prop_get(item, prop) 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_min'] = prop_ui['min'] = prop_type(self.min)
prop_ui['soft_max'] = prop_ui['max'] = prop_type(self.max) prop_ui['soft_max'] = prop_ui['max'] = prop_type(self.max)

View File

@@ -462,7 +462,7 @@ class PARTICLE_PT_physics(ParticleButtonsPanel, bpy.types.Panel):
col.prop(part, "mass") col.prop(part, "mass")
col.prop(part, "use_multiply_size_mass", text="Multiply mass with size") 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() split = layout.split()
col = split.column() col = split.column()
@@ -921,7 +921,7 @@ class PARTICLE_PT_render(ParticleButtonsPanel, bpy.types.Panel):
col = row.column() col = row.column()
col.label(text="") 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 = layout.row(align=True)
row.prop(part, "particle_size") row.prop(part, "particle_size")
row.prop(part, "size_random", slider=True) row.prop(part, "size_random", slider=True)

View File

@@ -18,7 +18,7 @@ class ModalOperator(bpy.types.Operator):
elif event.type == 'LEFTMOUSE': elif event.type == 'LEFTMOUSE':
return {'FINISHED'} return {'FINISHED'}
elif event.type in ('RIGHTMOUSE', 'ESC'): elif event.type in {'RIGHTMOUSE', 'ESC'}:
context.object.location.x = self.first_value context.object.location.x = self.first_value
return {'CANCELLED'} return {'CANCELLED'}

View File

@@ -45,7 +45,7 @@ class ModalDrawOperator(bpy.types.Operator):
context.region.callback_remove(self._handle) context.region.callback_remove(self._handle)
return {'FINISHED'} return {'FINISHED'}
elif event.type in ('RIGHTMOUSE', 'ESC'): elif event.type in {'RIGHTMOUSE', 'ESC'}:
context.region.callback_remove(self._handle) context.region.callback_remove(self._handle)
return {'CANCELLED'} return {'CANCELLED'}

View File

@@ -29,7 +29,7 @@ class ViewOperator(bpy.types.Operator):
context.area.header_text_set() context.area.header_text_set()
return {'FINISHED'} return {'FINISHED'}
elif event.type in ('RIGHTMOUSE', 'ESC'): elif event.type in {'RIGHTMOUSE', 'ESC'}:
rv3d.view_location = self._initial_location rv3d.view_location = self._initial_location
context.area.header_text_set() context.area.header_text_set()
return {'CANCELLED'} return {'CANCELLED'}

View File

@@ -70,7 +70,7 @@ def run_ops(operators, setup_func=None):
setup_func() setup_func()
for mode in ('EXEC_DEFAULT', 'INVOKE_DEFAULT'): for mode in {'EXEC_DEFAULT', 'INVOKE_DEFAULT'}:
try: try:
op(mode) op(mode)
except: except: