* Serhiy Storchaka wrote: > 01.03.12 16:47, André Malo написав(ла): > > On Thursday 01 March 2012 15:17:35 Serhiy Storchaka wrote: > >> This is the first rational use of frozendict that I see. However, a > >> deep copy is still necessary to create the frozendict. For this case, > >> I believe, would be better to "freeze" dict inplace and then > >> copy-on-write it. > > > > In my case it's actually a half one. The data mostly comes from > > memcache ;) I'm populating the object and then I'm done with it. People > > wanting to modify it, need to copy it, yes. OTOH usually a shallow copy > > is enough (here). > > What if people modify dicts in deep?
that's the "here" part. They can't [1]. These objects are typically ROLists of RODicts. Maybe nested deeper, but all RO* or other immutable types. I cheated, by deepcopying always in the cache, but defining __deepcopy__ for those RO* objects as "return self". nd [1] Well, an attacker could, because it's still based on regular dicts and lists. But thatswhy it's not a security feature, but a safety net (here). -- "Solides und umfangreiches Buch" -- aus einer Rezension <http://pub.perlig.de/books.html#apache2> _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com