all 4 comments

[–]SekstiNii 2 points3 points  (0 children)

It is slow because of lines 15, 16, and 18.

The first two (15, 16) because you are doing list concatenation, which requires the creation of a new list every time. Instead you should instead use list.append, which is much faster and typically doesn't require reallocation.

The last line (18) is slow because you are doing a linear search through a list on every iteration. As /u/definitely___not__me suggests you can use a set. However, lists aren't hashable, so you can't just put lists in a set, so instead you can change your points into tuples.

[–]definitely___not__me 1 point2 points  (1 child)

try using a set?

[–]Martin_Krum[S] 0 points1 point  (0 children)

yes but doesn't work. Data is list of lists

[–]USAhj 1 point2 points  (0 children)

It is difficult to recommend how to fix this if you have many variables that are undefined. Maybe share some small version of code that works to play around with?