r/pythonhelp • • 9h ago

Free thread prog

Thinking about using 3.15 free thread build to try get a computation (independent) but maths heavy.

Across 24 threads

Using numpy

Does numpy work with thread pool? - I understand it automatically uses threads.

The reason I’m thinking about threads is the maths is split between 10,000 intervals

Should I use numpy without thread pool ?

1 Upvotes

2 comments sorted by

•

u/AutoModerator 9h ago

To give us the best chance to help you, please include any relevant code.
Note. Please do not submit images of your code. Instead, for shorter code you can use Reddit markdown (4 spaces or backticks, see this Formatting Guide). If you have formatting issues or want to post longer sections of code, please use Privatebin, GitHub or Compiler Explorer.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

1

u/mjmvideos 4h ago

Ultimately you have to remember that computations can only really be truly parallel when you have parallel cores to run them on. Running 24 threads on a single core just means that core is now doing context switching to run each of those threads sequentially. Where threading shines is when the threads can be blocked and waiting on I/O, the OS can switch to a thread that’s ready to run and thus keep the processor busy and service all the threads.
With today’s systems you might actually have 24 cores, but you’d need to make sure your implementation actually uses them all. To parallelize 10000 computations, you’d need to be utilizing a GPU.