DETROIT — The Patriots’ defense took a nice step forward in Thursday night’s exhibition game against the Lions.

Say what? Did you even watch the game?

OK, obviously the 40-9 loss was not the result the Patriots were looking for. It was New England’s worst preseason loss since 2004, and Bill Belichick was his usual dejected self after the game, saying, “We got thoroughly outplayed and outcoached . . . Weren’t very competitive in anything.”

Except that’s an overly pessimistic view of the Patriots’ performance, particularly the starting defense. The offense was certainly putrid, committing four turnovers in the first half and scoring 3 points on nine drives. But the defense, playing without Vince Wilfork (rest) and using Jerod Mayo only in sub packages, had a respectable showing.

Consider that after the four turnovers, the Patriots only trailed, 16-3, at halftime. Tom Brady can erase that deficit in two second-half drives, had it been a regular-season game (he sat out the second half).

“That’s the crazy thing with football — it’s usually not as bad as you think it is,” said safety Devin McCourty, playing his first exhibition game after sitting out the first two following offseason shoulder surgery. “There’s a lot of things we could’ve done better, but we did some things well tonight.”

No doubt, they’d like to have that 67-yard catch-and-run by Reggie Bush back. And the 9-yard touchdown pass from Matthew Stafford to Tony Scheffler was too easy.

But the preseason is all about practicing scenarios, and before Thursday night, the Patriots’ starting defense hadn’t practiced any “sudden change” — having to go right back on the field after the offense commits a turnover.

Thursday night they got four opportunities to practice “sudden change,” including three drives that began in Patriots territory (two inside the red zone). And giving up just 16 points in those circumstances is a pretty solid effort.

The Patriots didn’t let the Lions into the end zone after Bush’s long run. They held the Lions to a three-and-out after Brandon Bolden fumbled at his 19, and David Akers missed the chip-shot field goal. They did allow the easy touchdown to Scheffler — backup linebacker Dane Fletcher badly bit on the play-fake — but they again held the Lions to a three-and-out after a Shane Vereen fumble gave Detroit the ball on New England’s 7-yard line.

“It’s either really terrible execution on [the Lions’] part, or we’re not giving this Patriots defense enough credit for getting off the field,” radio analyst Scott Zolak said during the broadcast.

Belichick was loathe to concede that it was good to have so many “sudden change” opportunities on Thursday — “I guess you could say that,” he deadpanned — but they’re going to happen at various points in the regular season, so it can’t hurt to practice them now when the games don’t count.

Before Thursday night, the Patriots’ starting defense had only faced two drives that began in their territory this preseason, and neither came in a “sudden change” situation.

“When you go into the locker room and it’s 16-3 with some turnovers in the red zone there, that’s a good feeling,” said linebacker Rob Ninkovich, who led the Patriots with six tackles and also added half a sack. “You look at the last couple games in the preseason, we haven’t had that situation come up. So again, any time that boom, you’re off the field, bang, you’re back on the field, you’ve got to go play football. That’s our job.”

Anyone who pays attention to the NFL knows that the Patriots’ defense hasn’t been as good as the offense over the last three or four seasons. They were second in the league with 41 takeaways last year, and the defense has ranked in the top 10 in points allowed in three of the last four seasons, but they’ve also given up a ton of yards, and were ranked 25th or lower in total defense in each of the last three years.

Thursday, though, the starting defense showed some signs of maturity and improvement, despite the lopsided score. It’s mostly the same unit as last year, except young guys such as Chandler Jones, Alfonzo Dennard (who didn’t play Thursday), Dont’a Hightower, and McCourty are now a year older and a year wiser.

“This year I think we have a good core group back,” McCourty said. “We want to play well, we feel like we have the personnel to do that, guys that want to do that, and this year, why not? Everyone’s hungry, and it just comes down to each week proving it.”

That’s why for some players, giving up the 16 points in the first half wasn’t good enough.

And the starting defense has only created one turnover in three exhibition games, a fumble recovery by Brandon Spikes.

“I think Bill probably wanted no points,” Tommy Kelly said with a chuckle. “You’ve got to find some way just to get the ball back to the offense, no matter what the situation is or where they get the ball.”

Fair enough, although creating turnovers hasn’t been an issue for the defense in recent years, and Belichick, who didn’t watch the offense Thursday night because he was coaching up the defensive players, will certainly unveil some exotic and confusing defenses in the regular season.

And the “sudden change” performance wasn’t the only positive for the defense. The first-team D held the Lions to 2 of 9 on third down in the first half. The Lions rushed eight times and gained just 3 yards in the opening half, as well.

If nothing else, everything about Thursday’s game was a good learning experience for this group, right down to the 40-9 butt-whipping.

“That’s the one thing you learn from a game like this — you can’t just expect to come in and have a great game unless you’re 100 percent in all three phases,” Ninkovich said. “And that’s a good lesson for us. Opened our eyes up.”