(May-03-2018, 06:07 AM)buran Wrote: You constantly check if subscriberId and protocolId already exists in the struct. I would bet it is slowing it down
you may want to explore dict.setdefault() and dict.get() methods and defaultdict from collections
check them and if you are not able to figure it post some sample data and I will make an example
Thank you for your reply! I've rewritten my function in this way:
struct.setdefault(contactId, {sectionId:0}) struct[contactId].setdefault(sectionId, 0) struct[contactId][sectionId] += octentsAnd I tried to use collections.defaultdict instead Python's dict, but unfortunately it didn't make the script significantly faster :(