Skip to content

Commit

Permalink
simplify with a few modern comprehensions.
Browse files Browse the repository at this point in the history
  • Loading branch information
jamadden committed Jun 29, 2016
1 parent 3029c44 commit 7e9f9a5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
3 changes: 1 addition & 2 deletions relstorage/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,7 @@ def __init__(self, adapter, options, prefix, local_client=None):

# self.clients_local_first is in order from local to global caches,
# while self.clients_global_first is in order from global to local.
self.clients_global_first = list(self.clients_local_first)
self.clients_global_first.reverse()
self.clients_global_first = list(reversed(self.clients_local_first))

# commit_count_key contains a number that is incremented
# for every commit. See tpc_finish().
Expand Down
18 changes: 8 additions & 10 deletions relstorage/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -1188,13 +1188,12 @@ def pack(self, t, referencesf, prepack_only=False, skip_prepack=False,
raise ValueError('Pick either prepack_only or skip_prepack.')

def get_references(state):
"""Return the set of OIDs the given state refers to."""
refs = set()
if state:
assert isinstance(state, bytes), type(state) # XXX PY3: str(state)
for oid in referencesf(state):
refs.add(u64(oid))
return refs
"""Return an iterable of the set of OIDs the given state refers to."""
if not state:
return ()

assert isinstance(state, bytes), type(state) # XXX PY3: str(state)
return {u64(oid) for oid in referencesf(state)}

# Use a private connection (lock_conn and lock_cursor) to
# hold the pack lock. Have the adapter open temporary
Expand Down Expand Up @@ -1363,9 +1362,8 @@ def poll_invalidations(self):
if changes is None:
oids = None
else:
oids = {}
for oid_int, _tid_int in changes:
oids[p64(oid_int)] = 1
# The value is ignored, only key matters
oids = {p64(oid_int): 1 for oid_int, _tid_int in changes}
return oids

@metricmethod
Expand Down

0 comments on commit 7e9f9a5

Please sign in to comment.