user4997438
user4997438

Reputation: 1

python Use python.dll Achieve Multithreading

I am a python novice, I gradually came to love python, but I'm not satisfied with its concurrent performance.

Multithreading is slow. Multi-process, slow loading, waste of resources.

So I thought, why not use Python. dll true multithreading.
It loads faster, runs faster, and save resources. Moreover, An process inner share data more quickly and safely. I am familiar with another scripting language, use this method. They can control each other, shared variables, but independent of each other, it is a true multi-threaded.

Who has similar experiences do, you're welcome to share.

Upvotes: 0

Views: 136

Answers (1)

Max Noel
Max Noel

Reputation: 8910

Python (the language runtime, therefore the DLL) is architectured in such a way (global variables everywhere) that it's currently impossible to have more than one Python VM running in the same process.

So no, you can't do that (not in Python, at least -- Lua allows multiple independent VMs running in the same process).

And even if you could, to share data between threads (which is a bad idea to begin with, but that's another topic) without compromising the runtime's integrity, you need the GIL. That's why it exists in the first place.

Upvotes: 1

Related Questions