Comment
Comment by haikuginger
Your script has what looks to be a pretty big inefficiency here[1] that's slowing it down. Looping over a set kills the constant-time presence-checking that you get from using that data structure; it will likely be much faster to do something like this:
The following would also work:
[1]https://gist.github.com/28mm/9820bd8b6eb27555efe9d6f46dd95a8...