Dictionaries and Threads

David Bolen db3l at fitlinxx.com
Fri May 26 19:13:42 EDT 2000


aahz at netcom.com (Aahz Maruch) writes:

> In article <3926A8EF.C3C1914B at jslove.net>, Jay Love  <jsliv at jslove.net> wrote:
> >
> >Are dictionary lookups threadsafe?
> >
> >ie, can I lookup and retrieve an item in a dictionary while another
> >thread is adding an item?
> 
> In general yes, if you do it in single lines of code:

Actually, I've been wondering about this sort of thing myself.  If I
understand correctly, under normal execution the interpreter will
relinquish control and permit a context switch every 'n' bytecode
instructions (n is configurable, but defaults to something like 10).

So is this suggestion just because the average line of code can be
encoded in less than 10 bytecodes (but what if the first 9 bytecodes
were used up in prior instructions) or is there some underlying
protection going on with data access?

--
-- David
-- 
/-----------------------------------------------------------------------\
 \               David Bolen            \   E-mail: db3l at fitlinxx.com  /
  |             FitLinxx, Inc.            \  Phone: (203) 708-5192    |
 /  860 Canal Street, Stamford, CT  06902   \  Fax: (203) 316-5150     \
\-----------------------------------------------------------------------/



More information about the Python-list mailing list