[Python-ideas] fork - other approaches
Sven R. Kunze
srkunze at mail.de
Sat Aug 1 19:29:04 CEST 2015
Thanks everybody for inspiring me with alternative ways of working with pools.
I am very certain that any them will work as intended. However, they do not zero in 100% on my main intentions:
1) easy to understand
2) exchangeable (seq par)
A) pmap
It origates from map and allows easy exchangeability back and forth sequential and concurrent/parallel execution.
However, I have to admit that I have difficulties to change all the 'for loops' to map (mentally as well as for real).
The 'for loop' IS the most used loop construct in business applications and I do not see it going away because of something else (such as map).
B) with Pool()
It removes the need to close and join the pool which removes the visual clutter from the source code. That as such is great.
However, exchangeability is clearly not given and the same issue concerning understandability like pmap arises.
C) apply
Nick's approach of providing a 'call_in_background' solution comes almost close to what would solve the issues at hand.
However, it reminds me of apply (deprecated built-in function for calling other functions). So, a better name for it would be 'bg_apply'.
All of these approaches basically rip the function call out of the programmer's view.
It is no longer
function(arg)
but
apply(function, arg) # or
bg_apply(function, arg) # or
bg_apply_many(function, args)
I don't see this going well in production and in code reviews.
So, an expression keyword like 'fork' would still be better at least from my perspective. It would tell me: 'it's not my responsibility anymore; delegate this to someone else and get me a handle of the future result'.
Best,
Sven
-------------------------------------------------------------------------------------------------
FreeMail powered by mail.de - MEHR SICHERHEIT, SERIOSITÄT UND KOMFORT
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20150801/99b990db/attachment.html>
More information about the Python-ideas
mailing list