3 ms·
Because there is no need for locking in the fundamental data-types like hashes.
by fuzzyman 16y ago
Because there is no need for locking in the fundamental data-types like hashes.
- viraptor 16y agoWhy would you lock anything in a sigle-threaded code in the first place?
- eykd 16y agoI don't know about Ruby, but in Python, the GIL is there to protect the interpreter from complicated locking and memory management overhead that thread-safety would require of it: http://mail.python.org/pipermail/python-3000/2007-May/007414.html http://mail.python.org/pipermail/python-3000/2007-May/007414... @jessenoller has a great summary of concurrency in Python: http://jessenoller.com/2009/02/01/python-threads-and-the-global-interpreter-lock/ http://jessenoller.com/2009/02/01/python-threads-and-the-glo... The two worlds seem very similar.
- viraptor 16y agoSure, I understand the idea of GIL being faster than fine-grained locking for single-threaded apps. This is not how I read the article though (maybe that's what they meant...). The speed can be sorted as (in most cases): single-threaded code, single-threaded with GIL, single-threaded with fine locks.