Re-assigning a name to itself
Solution 1:
This code occurs in multiprocessing.dummy
, a "fake" version of multiprocessing
that implements the functionality with threads. If you look down a few lines, you'll see
def Manager():
return sys.modules[__name__]
multiprocessing.dummy
implements Manager
as a function that just returns the multiprocessing.dummy
module itself, so the multiprocessing.dummy
module object has to provide the API of a multiprocessing Manager object. The lines
dict = dict
list = list
copy the bindings for the dict
and list
names from the builtins namespace into the module's namespace, so you can do
m = multiprocessing.dummy.Manager()
d = m.dict()
as if you had a real multiprocessing.Manager()
.