I ran some timings with timeit, and the multiple ands are about ten times faster than joining the strings, hashing and comparing the hashes.