0

I have a list of custom objects and I want to apply a method on each object which alters the internal memory of the objects. I want to be able to do this in parallel without having to return the objects afterwards.

Essentially I would like to have the equivalent of the for(/each) statement below but in parallel.

for env, p, v in zip(envs, policy, value):
    env.step(p, v)
1
  • Use lambda functions. Commented Jul 26, 2019 at 11:13

1 Answer 1

2

Since pure python does not allow multithreading with really parallel execution due to the global interpreter lock (https://realpython.com/python-gil/), you won't be able to execute your for-loop in parallel without inter-process communication, i.e. returning the object afterwards.

However, as the link says, this might change in the future. Alternatively you could use an alternative Python interpreter.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.