Dreaming about GIL
This post is older then 6 months, which means opinions contained were mine and
any technical information is most likely obsolete.
Please contact me for text I would also sign, not only acknowledge or if post got broken during one of many server upgrades. I will be most grateful.
Please contact me for text I would also sign, not only acknowledge or if post got broken during one of many server upgrades. I will be most grateful.
I’ve been thinking about Python’s global interpreter lock (GIL) again. Since I’m a glutton for punishment and haven’t been crucified in a week, you get to hear about it too.
Has anybody thought and wrote about avoiding GIL until you need it? What I mean is creating and using GIL only when you start using code that might not be thread-safe.
So, what’s wrong with this idea?
Things that come to my mind:
- garbage collector is not thread-safe
- majority of interesting modules are not thread-safe, so there would be little ROI
- dynamic nature of Python means you can’t know in advance if you’ll need GIL and it would a bitch to fall back when you do
- …
I guess it’s just a really stupid idea.
Posted: October 11, 2005 @ 3:38 pm in Python Comments (1)
The allocator is not threadsafe without the GIL. You cannot create any kind of Python object without the GIL or another similar lock.
So yea, this idea is pretty much DOA.
Comment by Jp Calderone — October 17, 2005 @ 4:55 am