Out of work and over 40? Consider the lucrative world of drug dealing.

That seems to be the new message from NYPD brass.

As The Post reported Wednesday, narcotics cops have been ordered to target drug dealers under 40 — who are far more likely to carry and use guns — than the older crowd. Narcotics cops who still arrest the over-40 dealers must explain why.

It started logically enough. Shootings are up sharply, raising fears of a resurgence in violent crime.

Police Commissioner Bill Bratton says the numbers show the spike is mainly a matter of drug crime.

And, as a May 14 memo from Assistant Chief Brian McCarthy, head of the Narcotics Division, notes, those between the ages of 18 and 40 “are responsible for the majority of violent crime.”

So focusing on those dealers seems smart enough — but at the expense of letting older drug suspects walk?

Bratton denied Wednesday that officers are “ignoring other types of arrests.” Well, McCarthy’s memo specifies that any arrest of an over-40 suspect must be cleared with a high-level officer — and that McCarthy will “personally review” any such activity.

That’s a pretty blunt message that anyone who drags in too many of the “wrong” dealers will be in for departmental hell.

Police sources also told The Post that cops have been threatened with transfers for arresting older suspects.

The implications aren’t good. Older dealers now know they can get a virtual free pass — and take over more of the drug trade as younger dealers are busted.

For another, as The Post reports today, those older dealers, when arrested, are a treasure trove of incriminating information on their younger, deadlier competitors.

Word would have leaked even if The Post hadn’t broken the story. Criminals study cop behavior carefully — and outraged officers were sure to get the word out to the public eventually.

We understand the NYPD must concentrate its limited resources, as Bratton says, “where we will have the maximum impact.” But there has to be a wiser way to do it.