Communities for your favorite technologies.  Explore all Collectives

Python 3.13 with free-thread is slow

submited by
Style Pass
2024-12-25 13:30:04

Communities for your favorite technologies. Explore all Collectives

Ask questions, find answers and collaborate at work with Stack Overflow for Teams. Explore Teams

I was trying this new free-thread version of the interpreter, but find out that it actually takes longer than the GIL enabled version. I did observe that the usage on the CPU increase a lot for the free-thread interpreter, is there something I misunderstand about this new interpreter?

The primary culprit appears to be the randint module, as it is a static import and appears to share a mutex between threads. Another problem is that you're only able to process 4 tables at a time. Since you want to create 10 tables in total, you'll be running batches of 4-4-2.

And here is some code that achieves the same thing, but is more flexible with the thread creation and avoids unnecessary inter-thread communication:

Leave a Comment