466
467 def copy(self):
468 gdgt = Gadget(self.arch)
469 gdgt.instList = [i for i in self.instList]470 gdgt.firstInst = self.firstInst
471 gdgt.gadgetMatrix = self.gadgetMatrix.copy()
472 gdgt.max_cost = self.max_cost
124 stackTop = gdgtCollection.arch.stackTop
125 sL = gdgtCollection.arch.stackLast
126
127 STACK_codes = [i for i in range(sF, sL + 1)]128 STACK_strings = ["stack_" + str(i - stackTop) for i in range(sF, sL + 1)]
129
130 deref = gdgtCollection.arch.deref
It is unnecessary to use a comprehension just to loop over the iterable
and create a list
/set
/dict
out of it.
Python has a specialized set of tools for this task: the list
/set
/dict
constructors, which are faster and more readable.
states = [
('AL', 'Alabama'),
('AK', 'Alaska'),
('AZ', 'Arizona'),
('AR', 'Arkansas'),
('CA', 'California'),
# ...
]
abbreviations_to_names = {
abbreviation: name
for abbreviation, name in states
}
states = [
('AL', 'Alabama'),
('AK', 'Alaska'),
('AZ', 'Arizona'),
('AR', 'Arkansas'),
('CA', 'California'),
# ...
]
abbreviations_to_names = dict(states)