On Sat, Jan 28, 2006 at 02:39:42AM -0800, Zac Medico wrote: > def _delitem(self, cpv): > try: > del self.db_rw[cpv] > except KeyError, ke: > if not self.db_ro.has_key(cpv): > raise ke
You need white outs here (lifting a unionfs term); this won't actually change state in any way if you're trying to delete a bad entry from the underlying metadata cache. > > def has_key(self, cpv): > return self.db_rw.has_key(cpv) or self.db_ro.has_key(cpv) > > def iterkeys(self): > s = set() > for db in (self.db_rw, self.db_ro): > for cpv in db.iterkeys(): > if cpv not in s: > yield cpv > s.add(cpv) Should just do s=set() for cpv in self.db_rw: yield cpv s.add(cpv) for cpv in self.db_ro: if cpv not in s: yield cpv Slightly faster (1us per yield for the set lookup), but mainly less memory usage. Aside from that, the label trick is icky. ;)
pgpKDjdHMWon3.pgp
Description: PGP signature