locking dictionaries (was Re: New statement proposal for Python)

Aahz Maruch aahz at panix.com
Thu Jun 21 02:09:37 CEST 2001

In article <3B30203F.B158D356 at my.signature>,
Greg Ewing  <see at my.signature> wrote:
>Aahz Maruch wrote:
>> OTOH, there's been some discussion of locking dicts during certain
>> operations to prevent some ugly bugs and crashes.
>I'm given to understand that, in the case of lists, this is achieved
>by temporarily changing the type pointer. If a similar thing were done
>for dicts, presumably it wouldn't have any effect on the performance of
>non-locked dicts.

Yes, it would (assuming I understand the discussion correctly), because
the code would be simplified by not needing the smarts to deal with
dicts mutating in the middle of operations.  I don't really know enough
to understand what I'm talking about, but it occurred to me that
possibly it might make sense to directly implement locked dictionaries
and then have the internals use the external API under the covers.
(You'd need a second "can't unlock this dict" variable for internal use,
but that would only slow down the dict.unlock() operation.)
                      --- Aahz  <*>  (Copyright 2001 by aahz at pobox.com)

Hugs and backrubs -- I break Rule 6                 http://www.rahul.net/aahz/
Androgynous poly kinky vanilla queer het Pythonista   

"It's not what you know, it's what you *think* you know."  --Steve Martin

More information about the Python-list mailing list