[ZDP] BackTalk to Document Zope Developer's Guide (2.4 edition)/ZODB Persistent Components
Fri, 06 Sep 2002 09:49:31 -0400
A comment to the paragraph below was recently added via http://www.zope.org/Documentation/Books/ZDG/current/Persistence.stx#3-56
One tricky type of non-persistent, shared objects are mutable
default arguments to functions, and methods. Default arguments
are useful because they are cached for speed, and do not need to
be recreated every time the method is called. But if these cached
default arguments are mutable, one thread may change (mutate) the
object when another thread is using it, and that can be bad. So,
% Anonymous User - Sep. 6, 2002 9:49 am:
need more explanation, please: what if foo is a method of class FooClass(Persistence.Persistent)? Does the
persistence machinery guarantee threadsafety for argument 'bar' or we are in trouble all the same?
Put another way, arguments of methods in persistent classes are persistent or not?