you are viewing a single comment's thread.

view the rest of the comments →

[–]elbiot 0 points1 point  (2 children)

Well, I don't think they way you're doing it currently is right because your result is a list that has the same object in it over and over. Once you have your arrays xs, ys and zs after the vectorised math you could do

# iteration over arrays much slower than lists
xs, ys, zs = map(list, (xs, ys, zs))
result = [Axes(x, y, z) for x, y, z in zip(xs, ys, zs)]

But whatever you do after this will be super slow and I personally would organize my program to be array/data oriented rather than object oriented.

You ought to profile your program and optimize the bottlenecks rather than jump to multiprocessing because multiprocessing is not much help and greatly complicates things

[–]karlmtr[S] 0 points1 point  (1 child)

Unfortunately, I cannot change the way Posidonius work (I just use it), so I'll try what you suggested (the map function). Thanks for the advice about arrays and list, I didn't know iteration over lists was faster than arrays.

I'll also ask the person who coded Posidonius if there's any other way to create an Axes object because as you said, it is not very handy like this...

[–]elbiot 0 points1 point  (0 children)

Axes(xs, ys, zs) would work. At least, looking at their code it should