performance - Python Function Takes too Long as Dictionary Gets too Big -
def assign_id(dic,id): key, value in enumerate(dic): elem in range(value): if id in dic[value]: return value
my function above want do-- problem dictionary dic gets bigger in main part of program, "assign_id" function takes long. function takes 1/100 of second run, after few thousand rows of input, starts take half second, full second , longer. trouble input file large function makes whole program take @ least 2 full days run.
is there way re-write above function runs quicker? able periodically run program want run faster does.
thank in advance help!
well, straight off bat, rid of enumerate
. also, second for-loop nothing. rid of too:
def assign_id(dic, id): key in dic: if id in dic[key]: return key
the above function should old 1 does, far faster.
Comments
Post a Comment