In 2022, Amazon (AMZN -0.40%) posted its first quarterly loss in years due to rising costs and a hefty loss on its investment in electric vehicle maker Rivian Automotive. It was a wake-up call that the company likely overestimated how much growth was on the horizon, and that it needed to cut back on hiring and slow down spending.

Amazon has adjusted, and it's not only back in the black, but its profits also look incredible. Let's review.

Profit margins are near record levels

One negative about Amazon's business has been that it typically doesn't generate high profit margins. It operates similar to big-box retailers that rely on significant volume, but because they compete on price, their margins aren't great. That puts the company at risk of incurring a loss when costs unexpectedly spike or demand is underwhelming.

But now, with Amazon slashing expenses and focusing on becoming leaner, the business is more profitable than it has been in recent periods. Last quarter, which ended on Sept. 30, Amazon's net income came in at just under $9.9 billion, which was more than three times the $2.9 billion it generated in the same period last year.

Its profit margin of 6.9% was also high compared to what the e-commerce giant has averaged over the past decade:

AMZN Profit Margin (Quarterly) Chart

AMZN profit margin (quarterly) data by YCharts.

The company is doing far better than its 10-year average, and its profit margin is now higher than it was before the pandemic began.

An encouraging trend to monitor

Amazon's expenses did rise this past quarter, but what was important was that revenue rose at a higher rate. That's a good recipe for success -- if expenses are accelerating faster than revenue is, that's going to result in a worsening bottom line.

Last quarter, Amazon's revenue totaled $143.1 billion and was up 13% year over year. Operating expenses of $131.9 billion rose by only 6%, leaving a healthy gap for the company to improve its margins.

Over a five-year period, that hasn't always been the case. But as investors will see from the chart below, the gap between revenue growth and operating-expense growth is shrinking, a very positive trend.

AMZN Revenue (Quarterly) Chart

AMZN revenue (quarterly) data by YCharts.

Is Amazon a good buy?

Amazon rarely ever looks like a cheap stock. Based on analyst estimates, it's trading at 43 times its future profits. That's a steep premium for a business that's growing at a rate of only 13%.

Alas, this is Amazon, the best e-commerce site in the world. Its dominance in the market is why investors are willing to pay a premium for the stock -- it's hard to find another brand as strong in e-commerce.

But there's reason to remain bullish. The company has recently rolled out a robotics system at a warehouse in Houston that should lead to more efficiencies and cost reductions thanks to artificial intelligence.

Amazon always pushes the envelope, trying to get things done faster and cheaper. And it's that endless pursuit of innovation and efficiency that suggests its profits can continue to improve over time.

The company's dominance in e-commerce and its strong brand make this a growth stock worth buying despite its high valuation since it's only likely to get bigger and more valuable in the years ahead.