today i had a problem with a customer tnef mail. It took around 150ms to call decode_mapi. Because it is called several times within tnefparse and within my code, it took around 2500ms to handle a request to this file.
I searched for the bottleneck with cProfile and found the problem:
In decode_mapi the var num_vals is a int bigger then several millions. Python will generate a list this big...
Solution: do not generate this big list, just use a iterator: xrange()
Hello,
today i had a problem with a customer tnef mail. It took around 150ms to call
decode_mapi
. Because it is called several times within tnefparse and within my code, it took around 2500ms to handle a request to this file.I searched for the bottleneck with cProfile and found the problem:
In
decode_mapi
the varnum_vals
is a int bigger then several millions. Python will generate a list this big... Solution: do not generate this big list, just use a iterator: xrange()Speed change: 2500ms > 60ms