The fundamental difference between filtering by race and filtering by gender is that one is by race and one is by gender. They’re not the same thing, and we don’t need to pretend that they are.
Separate bathrooms is most certainly not related to the Puritans, as we can observe equal or more bathroom separation across almost all religions and in all countries.
I don’t even think unified bathrooms are really becoming more popular outside the relatively small bubble that has been influenced by trans-activism. Even then, most of them are for a single occupant, which doesn’t really count, but satisfies everyone.
They're the same in that you don't get a choice in either case before your birth.
You would be treating people differently based on something they have no influence over, instead of actually recognizing them as a individual who can make their own choices.
If you decide that discriminating based on race or sex (or anything else you're born with) is okay, you're starting down a slippery slope with a running start and no more obvious stops in sight. Best not to start with this at all.
I also don't know that sexual assault is the reason for segregated bathrooms and locker rooms. I was always under the impression that it was just a puritanical artifact from an older time. Unified bathrooms are becoming more popular; I am curious if that has had any impact on sexual assault rates.