mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-01-11 12:42:34 +01:00
Optimization.
This commit is contained in:
parent
c84e8ff8fa
commit
6ba2120f5f
@ -308,15 +308,13 @@ class DB(object):
|
||||
yield record
|
||||
|
||||
def random(self):
|
||||
# XXX This can be optimized not to deserialize each record.
|
||||
try:
|
||||
return random.choice(self)
|
||||
return self._newRecord(*random.choice(self.map))
|
||||
except IndexError:
|
||||
return None
|
||||
|
||||
def size(self):
|
||||
# XXX Likewise as above.
|
||||
return ilen(self)
|
||||
return ilen(self.map)
|
||||
|
||||
def flush(self):
|
||||
self.map.flush()
|
||||
|
Loading…
Reference in New Issue
Block a user