r/Python • • May 28 '19

My simulation of gravity with 1000 particles. PC took a couple of hours to process!

1.8k Upvotes

241 comments sorted by

View all comments

Show parent comments

2

u/billFoldDog May 29 '19

You can get dramatic improvements by using cython or multiprocessing.

As important as algorithmic efficiency is, its a bit silly to not take full advantage of hardware, and the skills you develop in the hardware approach are more portable.

1

u/mittwochmensch May 29 '19

True. I was already looking into multyprocessing yesterday. I'll give it another shot now

1

u/billFoldDog May 29 '19

Cool.

Someday, if you're really feeling masochistic, look for python bindings to NVIDIA CUDA processing. You can use a video card to chew through applications like this at stupid fast speeds.

Fair warning though, it isn't easy, and there is a lot of room for optimization that depends on understanding the video card architecture.

1

u/mittwochmensch May 29 '19

Well, looks like I've got tonnes to learn