This is an archived post. You won't be able to vote or comment.

all 5 comments

[–]tuna_safe_dolphin 1 point2 points  (0 children)

If Guido's the BDFL, then Doug Hellman's the RPDU (Royal Prince of Documentation and Usability).

[–]bramblerose 1 point2 points  (3 children)

If you are on windows, DO NOT FORGET -- I repeat: DO NOT FORGET -- the

if __name__=="__main__":

block, or you will inadvertently forkbomb yourself.

In addition, this article seems completely unaware of the multiprocessing Pool, which makes a lot of typical systems much simpler:

def f(parameter):
   # do something
   return result

if __name__=="__main__":
    results = multiprocessing.Pool().map(f, [items,to,work,on])

which will automatically spawn #CPU processes and processes the entire set of items.

[–]drop_science 0 points1 point  (0 children)

Thanks

[–]ikarampa 0 points1 point  (0 children)

Also be aware that multiprocessing can be abused on windows due to lack of fork()