Re: SVN: zope.interface/branches/jinty-mem/src/zope/interface/interface.py Improve CPU performance of previous memory optimization

Brian Sutherland <[email protected]>
Newsgroups gmane.comp.web.zope.devel
Message-ID <[email protected]>
On Tue, Nov 09, 2010 at 03:01:09PM -0500, Tres Seaver wrote:
> > I think the is a possible threading issue with Element.setTaggedValue
> > and Specification.subscribe - if two threads called the method
> > concurrently, then one of the values might be lost. I think the
> > correct way to do it would be:
> > 
> >     tv = self.__tagged_values
> >     if tv is None:
> >         tv = self.__dict__.setdefault('_Element__tagged_values', {})
> >     tv[tag] = value
> > 
> > This does bring the name mangling back though.

Thanks, I fixed the threading issue in Specification.subscribe. Given
that that part of subscribe is not run very often, I think we can live
with limited name mangling.

> I'm pretty sure we can safely neglect threading issues here:  no sane
> code will call 'setTaggedValue' except at import time, when we should be
> serialized by Python's own import lock.

Great, I quoted you on that ;)

The setdefault fix for the threading issue is not compatible with the
use of __slots__. I couldn't find another way to do it.

-- 
Brian Sutherland
_______________________________________________
Zope-Dev maillist  -  [email protected]
https://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 https://mail.zope.org/mailman/listinfo/zope-announce
 https://mail.zope.org/mailman/listinfo/zope )
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.