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

Greg Ewing see at my.signature
Wed Jun 20 00:02:07 EDT 2001


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.

> would it maybe make
> sense to add an external interface to the locking mechanism?

Hmmm... wild thought: after type/class healing,
every object will have a __class__ attribute...
if it were changeable...

  d = {'spam':42}
  d.__class__ = MyLockedDictClass

No, probably far too dangerous...

  x = []
  x.__class__ = 3.__class__
  print x

<<<fireworks as python interpreter self-destructs>>>

-- 
Greg Ewing, Computer Science Dept, University of Canterbury,	  
Christchurch, New Zealand
To get my email address, please visit my web page:	  
http://www.cosc.canterbury.ac.nz/~greg



More information about the Python-list mailing list