Regarding the gender aspect, the behaviors you describe sound to me like textbook microaggressions. As as this McKinsey article explains:
Everyday sexism and racism, also known as microaggressions, can take many forms. Some can be subtle, like when someone mistakenly assumes a coworker is more junior than they really are. Some are more explicit, like when someone says something demeaning to a coworker. Whether intentional or unintentional, microaggressions signal disrespect. They also reflect inequality—while anyone can be on the receiving end of disrespectful behavior, microaggressions are directed at people with less power, such as women, people of color, and lesbian, gay, bisexual, transgender, and queer people.
Notably, one needn't be a misogynist or even consciously sexist to take part in microaggressions. You mentioned that you get along relatively well otherwise. I think there's a good chance he doesn't realize he's treating you differently, because he has yet to see in himself these incorrect notions based on your gender, let alone how they can cause him to act unfairly to you. Unfortunately, it probably wouldn't help for you to point this out to him, since those same notions would likely prevent him from really listening.
I think some of the other answers have offered good advice on how to carefully handle the issue of general disrespect without the gender aspect. But if you're interested in trying to improve the sexism issue (which I don't mean to imply is your responsibility by any means), I suggest discussing it with trusted male coworkers and, if they also believe there's a larger issue, encouraging them to be more active "workplace allies" as described in "workplace allies"this ELI article. This could make them more likely to help in situations like this, such as "by endeavoring to point out the unfairness in microaggressive remarks", and while it likely won't fix anything immediately, it could help promote fairness in the long term.
(Disclaimer: I am a male software engineer and not an expert on this topic.)