functools.partial creates a function object that contains the partial argument list. Since this object is created in the master process and it is not available in the worker process, it will be sent to the worker process with each work request; hence, this solution will be equivalent to the solution without the initializer.

If you benchmark the solution by switching the order of parameters/arguments on line 8 and 58, dropping the initilizer and aux_data on line 33, and using functools.partial(worker, aux_data) instead of with_initializer_worker_wrapper on line 37, then you will see the run times for with and without initializers are comparable.

Hope this helps,

Written by

Programming, experimenting, writing | Past: SWE, Researcher, Professor | Present: SWE

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store