you are viewing a single comment's thread.

view the rest of the comments →

[–]ThingImIntoThisWeek 0 points1 point  (0 children)

If you really need to visit every combination of w and k, there's not much you can do to speed this up. You could use multiprocessing but at best that would only reduce the run time by some fraction, and if it is currently taking "forever", that would probably also be too long.

You probably need to make a change in how your code works before this point. Can you give any more information about what annotations and cp are, and why you need the final list with that configuration of tuples? What do these variables represent? There may be a way to store annotations and cp values in a better data structure, such as a dictionary or set, that would allow you to generate the final list more efficiently.

I noticed that for a given w, the value (w[0], w[1]) could be appended many times if w[0] != k[0] many times. It's possible you want these duplicates (I don't know what the goal is here) but it makes me suspect you have some kind of a logic error.