multithreading and shared dictionary

K.S.Sreeram sreeram at tachyontech.net
Sat Jul 8 10:22:24 EDT 2006


Marc 'BlackJack' Rintsch wrote:
>>> Wrong, alas: each assignment *could* cause the dictionary's internal
>>> structures to be reorganized (rehashed) and impact another assignment
>>> (or even 'get'-access).
>> but wont the GIL be locked when the rehash occurs?
> 
> If there is a GIL then maybe yes.  But the GIL is an implementation
> detail.  It's not in Jython nor IronPython and maybe not forever in
> CPython.  Don't know about PyPy.

Just wondering.. Is this simply a case of defensive programming or is it
an error? (say, we're targeting only CPython).
For instance, what happens when there's dictionary key with a custom
__hash__ or __eq__ method?

Its probably wise to simply use a lock and relieve ourselves of the
burden of thinking about these cases. But it still is worth knowing...

Regards
Sreeram

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 260 bytes
Desc: OpenPGP digital signature
URL: <http://mail.python.org/pipermail/python-list/attachments/20060708/c960150e/attachment.sig>


More information about the Python-list mailing list