making a valid file name...

Neil Cerutti horpner at
Tue Oct 17 13:19:20 EDT 2006

On 2006-10-17, Tim Chase <python.list at> wrote:
> If you're doing it on a time-critical basis, it might help to
> make "valid" a set, which should have O(1) membership testing,
> rather than using the "in" test with a string.  I don't know
> how well the find() method of a string performs in relationship
> to "in" testing of a set.  Test and see, if it's important.

The find method of (8-bit) strings is really, really fast. My
guess is that set can't beat it. I tried to beat it recently with
a binary search function. Even after applying psyco find was
still faster (though I could beat the bisect functions by a
little bit by replacing a divide with a shift).

Neil Cerutti
This is not a book to be put down lightly. It should be thrown
with great force. --Dorothy Parker

More information about the Python-list mailing list