Alison Brie and Jason Sudeikis play each other’s sex coaches. Photo: Linda Kallerus/Courtesy of IFC FIlms

There’s a kind of headlong artist who works quickly, in an agitated state, not always knowing what he or she is going for but knowing when it’s gotten. That’s how I think of Leslye Headlong — sorry, Headland — writing the romantic comedy Sleeping With Other People. The story of a nonsexual but sexually charged friendship between a woman and a man, it feels as if it were streaming from the brain of someone who has seen When Harry Met Sally more than twice and is furiously reworking it to fit her own reality — adding lots more casual sex and emotional weirdness and roughening up the edges. Sleeping With Other People is a rare American non-homogenized rom-com, and it’s delightful even when you’re not sure what you’re watching.

You are sure, however, that Alison Brie and Jason Sudeikis are adorable together. The movie’s first big departure from convention is having them take each other’s virginity in the prologue — in college, as strangers, on a whim when a drunken Lainey (Brie) can’t find the teaching assistant she has a crush on. Thirteen years later, Headland reintroduces Lainey in a restaurant telling her boyfriend that she cheated on him — 16 times, but with the same person. Sudeikis’s Jake, meanwhile, is enduring the wrath of a woman who has just discovered that he cheated on her with her best friend. Neither, it appears, is capable of monogamy. Lainey will always rush back to the same teaching assistant, now an exceedingly twerpy doctor (Adam Scott) who happens to float her boat sexually. And Jake — well, who knows why he feels compelled to sabotage every relationship?

This is a dissonant, fits-and-starts movie without the usual metronomical rom-com perkiness. Lainey and Jake stumble on each other at a 12-step sexual-addiction meeting that nothing more comes of — they continue to dysfunction as they always have. Oddly nervous, they take awhile to decide to be friends instead of lovers, even coining a safe word — mousetrap — for when one thinks the other is edging too close to the sexual line. Of course, almost all they talk about is sex — with other people. The film’s big Katz’s Deli set piece is when Jake teaches Lainey how to give herself pleasure, the phrase Mind the gap acquiring a tantalizing new meaning. They’re both such smart people: What, we wonder, do they have to push through to be together? I’m not convinced Headland knows, apart from the fact that they must be, eventually. Mustn’t they?

Sudeikis has never been so appealing onscreen. His Jake is just the sort of sharp, funny, attentive guy whose vibe suggests he really, really likes women even if he doesn’t — or doesn’t know what he likes or doesn’t like, which is what makes him dangerous. Brie’s Lainey is more visibly unhinged, acting just as Jake describes her — a waif so sexily vulnerable she makes men want to say, “I can solve your problems with my penis.”

Headland — whose first film was the scabrous ensemble comedy Bachelorette — supplies a great group of friends and confidants. Jason Mantzoukas is the family man with whom Jake invents a piece of software that will make them millions, and he and Andrea Savage as his wife are such a funny Greek chorus that Headland gives them almost the entire closing-credit sequence to riff. (It’s one of the best things in the movie.) Natasha Lyonne is Brie’s gal pal and sounds so much like Marge Simpson she makes you giggle more at what she might say than what she does. Adam Scott performs a charisma-rectomy on himself to make the doctor dull in every way — which is why Brie’s attraction to him is so weirdly fascinating. Amanda Peet is the head of the company that makes Jake rich and the object of his romantic attentions. She knows enough to keep him at bay — until she yields, because she trusts him. Her final scene doesn’t fit into the standard rom-com template. Good.

Trailers don’t begin to convey the charm of Sleeping With Other People, because the people who create them look for the kind of conventional beats that Headland means to subvert — hence the oft-misused adjective (that in this case really does apply) offbeat. The film is not quite a screwball comedy, but the emotions are screwball — zigzaggy and un–pin-downable. No big Hollywood studio reportedly wanted to make it, which is enough to keep talented directors (and film lovers) up at night. Can’t studios hire people who don’t just want to sleep with superheroes or *shudder* Judd Apatow?

*This article appears in the September 7, 2015 issue of New York Magazine.