0

hi
i have this line in my code that seems to slow down as my loop progresses..

for i in range(start, end):
nPack = struct.pack('<I',i)

at first it takes about 0.00something second but later it starts to take like 0.12 sec.
i have huge no of different start and end pair so that is a big slow down.
has this happened to anyone before?
any idea what might be slowing down my program?

3
Contributors
2
Replies
3
Views
5 Years
Discussion Span
Last Post by woooee
0

Explain what you are trying to do, and post whole relevant function. Probably you have wrong algorithm for the job. Also maybe you should be using xrange if the length of the range is big and you use Python 2. In my computer struct.pack() looks like taking around 0.88 microseconds.

Edited by pyTony: n/a

0

"Why is this taking so long" is a question that is too general for you to answer. So learn to use profiling. The first few sentences read
"The first step to speeding up your program is learning where the bottlenecks lie. It hardly makes sense to optimize code that is never executed or that already runs fast. I use two modules to help locate the hotspots in my code, profile and trace."

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.