オブジェクトのリストを含むオブジェクトがあります。私は次のようなことをしたいと思います:
def compute_weight(particle, data):
particle.weight = run_computation(data)
class SomeClass:
def __init__(self):
self.particles = [obj1, obj2, etc]
def run(self, data):
[compute_weight(particle, data) for p in self.particles]
これらは独立して実行できますが、更新された各パーティクルを含めるには self.particles が必要です。現在、2つの引数をpool.map関数に押し込むトリックがあります
# equivalent function as above
pool.map(compute_weight_star, itertools.izip(self.particles,
itertools.repeat(data)))
しかし、各particle.weightは更新されていないようです。私は何を間違っていますか?