The only thing I think could affect readability is the declaration of to_thread (and its imports) under a conditional logic. I would have the conditional implemented under to_thread instead, and move the imports to the file header. But this is really just a coding styling thing, so feel free to do what feels natural for you 😄
Yeah, I didn't want to litter the top level with imports that won't get used by the majority of our clients. So if I move the conditional inside a function call (with the imports), then it will effectively lazy import on the first call, which could lead to a perf drop on the first pass.
Yeah, I didn't want to litter the top level with imports that won't get used by the majority of our clients. So if I move the conditional inside a function call (with the imports), then it will effectively lazy import on the first call, which could lead to a perf drop on the first pass.