Here’s a film that could easily have been tasteless, leering, and puerile, but instead Tanya Wexler’s Hysteria is funny, charming, warm, smart, and probably the best romantic comedy since Miss Pettigrew Lives for a Day back in 2008. OK, so maybe it is a little bit tasteless. This is, after all, the story of the invention of the personal vibrator in Victorian England. And, yes, it is fact based (“Really,” a title assures us), but all in all, it seems much more fanciful than factual, though it’s unlikely that anyone is going to care much about that — especially when the fanciful is this much fun and the fun is this clever. And like all the best romantic comedies (those that deserve the full term and not the dismissive rom-com tag), there’s more going on here than meets the eye. It’s also about women’s rights, personal realization, and the difficulties of overcoming hidebound, entrenched ideas.

The film’s title comes from the then-common medical practice of labeling all manner of female complaints (especially anything related to sex and sexuality) with the catch-all term “hysteria.” The story here is that of a young doctor, Mortimer Granville (Hugh Dancy), who has been kicked out of a number of positions over his new-fangled ideas about germs and infections and ends up in the employ of upscale specialist Robert Dalrymple (Jonathan Pryce), whose specialty lies in treating women diagnosed with hysteria. The treatment for the condition involves the use of peculiarly demure curtained enclosures so the patient can’t watch as the doctor manually induces a “paroxym” to alleviate the condition. (The word orgasm never crops up in the film.) Not surprisingly, the young, good-looking Granville becomes very good for business, pleasing Dalrymple to no end.

In the bargain, Granville finds himself part of the Dalrymple household, which includes Dalrymple’s accomplished (as in she plays the piano and studies phrenology) and dutiful daughter Emily (Felicity Jones, Like Crazy), and, occasionally, her older sister, the far from dutiful Charlotte (Maggie Gyllenhaal), who not only promotes women’s suffrage, but she runs a help center in the slums and is very outspoken. She’s also saddled the household with a (not very) reformed prostitute, Molly (Brit TV actress Sheridan Smith), who frequently disconcerts Granville with her indelicate overtures.

It is not the most settled of households, though Granville adapts to it well enough, even to the extent of becoming virtually engaged to Emily. But he ultimately can’t adapt to the damage to his hand the job induces. And that leads to his discharge, until he prompts his experimentally inclined, dissolute friend Edmund St. John-Smythe (Rupert Everett) to adapt his prototype electric feather duster into the personal vibrator.

All that may seem like most of the story, but it’s really little more than the set-up for the film’s surprisingly involved tale — and it scarcely gives any indication of how stylish and clever the whole thing is. I’m sure it gives away nothing to note that Granville has taken up with the wrong daughter, but knowing that gives no sense of how beautifully that part of the story is handled.

Wexler’s direction is flawless throughout, but much of what makes Hysteria such an unalloyed pleasure lies in its array of absolutely enchanting performances. For starters, this is the best break Everett has had in years, and at last we have a movie that knows what to do with the underrated Dancy. In fact, everyone is absolutely perfect, but the standout is Gyllenhaal affecting an English accent and showing the kind of poise, conviction, and humor I haven’t seen since the early days of Diana Rigg. You won’t find a better time at the movies these days.