set
is as fast as it gets.
However, if you rewrite your code to create the set
once, and not change it, you can use the frozenset
built-in type. It's exactly the same except immutable.
If you're still having speed problems, you need to speed your program up in other ways, such as by using PyPy instead of cPython.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…