get_attrs uses list.append()

Appending to the list should be slightly faster than using +=
This commit is contained in:
Bryan Schumaker 2010-12-11 21:54:36 -05:00
parent 6957cc96f6
commit 4a3e6184ab

View File

@ -149,22 +149,23 @@ def get_attrs(id, *attrs):
get = rec.__dict__.get
tags = rec.tags.walk_vals_backwards()
append = res.append
for attr in attrs:
if attr == "id":
res += [id]
append(id)
elif attr == "filepath":
res += [rec.fs.walk_path_backwards()]
append(rec.fs.walk_path_backwards())
elif attr == "art":
from libsaria import lastfm
res += [lastfm.get_artwork_id(id)]
append(lastfm.get_artwork_id(id))
elif attr == "artist":
res += [tags[0]]
append(tags[0])
elif attr == "album":
res += [tags[1]]
append(tags[1])
elif attr == "title":
res += [tags[2]]
append(tags[2])
else:
res += [get(attr, None)]
append(get(attr, None))
if len(res) == 1:
return res[0]
return res