faster sorting syntax in python, try/except for py 2.3 backwards compat

ls.sort(key = lambda v: v.foo)
rather then
  ls.sort(lambda a,b: cmp(a.foo, b.foo))
This commit is contained in:
2006-12-14 14:53:32 +00:00
parent 4b99060cc3
commit b995593eee
8 changed files with 52 additions and 18 deletions

View File

@@ -152,7 +152,8 @@ def mesh_mirror(me, PREF_MIRROR_LOCATION, PREF_XMID_SNAP, PREF_MAX_DIST, PREF_XZ
# Now we have a list of the pairs we might use, lets find the best and do them first.
# de-selecting as we go. so we can makke sure not to mess it up.
mirror_pairs.sort(lambda a,b: cmp(a[0], b[0]))
try: mirror_pairs.sort(key = lambda a: a[0])
except: mirror_pairs.sort(lambda a,b: cmp(a[0], b[0]))
for dist, v1,v2 in mirror_pairs: # dist, neg, pos
if v1.sel and v2.sel: