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:

    tags = list(set(descr.split()) & categories)
The following would also work:

    tags = [x for x in descr.split() if x in categories]

[1]https://gist.github.com/28mm/9820bd8b6eb27555efe9d6f46dd95a8...
parent haikuginger 8 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton