A CPU-bound endpoint is too slow. What are the options and what do they cost?
Roughly: move the work off the request into a queue, parallelise with processes rather than threads, push the hot loop into C or Rust via an extension, or change the algorithm. The last is usually the cheapest and the one people skip. Multiprocessing costs you serialisation of everything crossing the boundary; an extension costs you build complexity and a second language in the repo.