A slightly better ThreadPoolExecutor in Pystd through types 0 ▲ Nibble Stew 1 hour ago · Tech · hide · 0 comments In the previous post we looked at a simple multithreaded task executor that behaves roughly like its Python standard library counterpart. The biggest missing feature was being able to return values from run tasks via future objects. In a fully dynamic language like Python this is fairly straightforward, whereas in a language with static typing, such as C++, things are trickier.The simplest solution is merely to make your Executor class a template, parameterized by the function you want to run. The obvious downside is code bloat. If your program has an Executor<Foo> and Executor<Bar>, all of their code is duplicated in the binary, even though 90% of it is probably the same. Also, due to the magic of template instantiation, compilation is slower. Another downside is that you can't run tasks that do different things, especially having different return value types, with one Executor.I set about trying to solve both of these issues at the same time. It turned out that if you are willing to… No comments yet. Log in to reply on the Fediverse. Comments will appear here.