it is a big part of very complex class.# Auto XXX if action == 'XXX': Relation = self.GetAXXXRelation(cid, cType) if AXXXRelation: product_AXXX = self.actionModel.ProductManager.GetProductAttrByName("AXXX") if not self.Company[cid].Customer[cust_ID].PriceSet[product_AXXX.ID].priceType == self.priceInterface.PRICETYPE_GLOBAL: for c_record in AXXXRelation: if c_record[0] == tour_id: action = 'AXXX' break
GetAXXXRelation returns a list of tuples to consider - in most cases this list is big.
It contains basic information about transactions that have to be handled in other way.
This part is located in big loop that iterates and transforms all transactions.
Isn't it more nice to use python built-in functions? it might work in the same ( AFAIR 'in' is optimized ) .
Lets look on this example
now comes funny part, because lists are sorted.XXXTransaction id list [2,4,6,8...] allTransaction id list [1,2,3,4...]
Checking if first elements are in XXX lists is quite easy but it is more expensive on the end of list :)
Hint for solution - it will help with code understanding and might be faster!
# Auto XXX if action == 'XXX': #that have to be performed on higher level - to not iterate it on each transaction #I've placed it only to show that now it is list of id not tuples AXXXRelation = [x[0] for x in self.GetAXXXRelation(cid, cType)] if AXXXRelation: product_AXXX = self.actionModel.ProductManager.GetProductAttrByName("AXXX") if not self.Company[cid].Customer[cust_ID].PriceSet[product_AXXX.ID].priceType == self.priceInterface.PRICETYPE_GLOBAL: if tour_id in AXXXRelation: # for c_record in AXXXRelation: # if c_record[0] == tour_id: action = 'AXXX' # break