Commits

Michał Górny  committed ccd70d3

Use itertools whenever feasible.

  • Participants
  • Parent commits 0171724

Comments (0)

Files changed (2)

File gentoopm/paludispm/pkg.py

 # (c) 2011 Michał Górny <mgorny@gentoo.org>
 # Released under the terms of the 2-clause BSD license.
 
+import itertools
 import paludis
 
 from ..basepm.depend import PMRequiredUseAtom
 	@property
 	def homepages(self):
 		spec = self._get_meta(self._pkg.homepage_key())
-		return SpaceSepTuple([str(x) for x in spec])
+		return SpaceSepTuple(itertools.imap(str, spec))
 
 	@property
 	def keywords(self):
 		kws = self._get_meta(self._pkg.keywords_key())
-		return SpaceSepFrozenSet([str(x) for x in kws])
+		return SpaceSepFrozenSet(itertools.imap(str, kws))
 
 	@property
 	def slot(self):

File gentoopm/portagepm/pkg.py

 # (c) 2011 Michał Górny <mgorny@gentoo.org>
 # Released under the terms of the 2-clause BSD license.
 
+import itertools
 from portage.versions import cpv_getkey, cpv_getversion, vercmp
 
 from ..basepm.depend import PMRequiredUseAtom
 		return PortagePackageVersion(self._cpv)
 
 	def _aux_get(self, *keys):
-		val = [str(x) for x
-				in self._dbapi.aux_get(self._cpv, keys)]
+		val = itertools.imap(str, self._dbapi.aux_get(self._cpv, keys))
 		if len(keys) == 1:
-			return val[0]
+			return next(iter(val))
 		else:
 			return tuple(val)
 
 		return self._dbapi.getRepositoryName(self._tree)
 
 	def _aux_get(self, *keys):
-		val = [str(x) for x in self._dbapi.aux_get
-				(self._cpv, keys, mytree = self._tree)]
+		val = itertools.imap(str, self._dbapi.aux_get(self._cpv,
+				keys, mytree = self._tree))
 		if len(keys) == 1:
-			return val[0]
+			return next(iter(val))
 		else:
 			return tuple(val)