7 ms·
Being able to do a multi-threaded map() would be divine. In Python, you're creating/destroying a new process and using IPC to seed the state info and return the
by Stubb 7y ago
Being able to do a multi-threaded map() would be divine. In Python, you're creating/destroying a new process and using IPC to seed the state info and return the results for each element in the iterable arg. If the function in question runs quickly, it ends up being faster to do it single threaded.
- Grinnz 7y agoIt's not going to be efficiently threaded like in Raku, but this is also possible in Perl 5 with a few modules from CPAN. https://metacpan.org/pod/IO::Async::Function https://metacpan.org/pod/IO::Async::Function will maintain a preforked pool of processes (on Unix) or threads (on Windows), and return Futures, which can be used by fmap_concat from https://metacpan.org/pod/Future::Utils https://metacpan.org/pod/Future::Utils to make a very map-looking iteration. The experimental https://metacpan.org/pod/Future::AsyncAwait https://metacpan.org/pod/Future::AsyncAwait will make this even more natural in the future.
- Stubb 7y agoI'm continually astounded that threading involves jumping through so many hoops in 2019. If you want a language that provides a REPL and easy threading, your choices are few and far between.