[Python-ideas] thread safe dictionary initialisation from mappings: dict(non_dict_mapping)
solipsis at pitrou.net
Tue Nov 20 19:30:44 CET 2012
On Tue, 20 Nov 2012 10:33:53 +0100
<a.kruis at science-computing.de> wrote:
> It is the automatic locking. For list- and set-like collections it is
> already possible to implement this kind of automatic locking, because
> iterating over them returns the complete information. Mappings are
> special because of their key-value items.
> If automatic locking of a collection is the right solution to a
> particular problem, depends on the problem. There are problems, where
> automatic locking is the best choice. I think, python should support it.
Automatic locking is rarely the solution to any problem, especially
with such general-purposes objects as associative containers. In many
cases, you have a bit more to protect than simply the dict's contents.
Most of Python's types and routines promise to be "safe" in the face of
threads in the sense that they won't crash, but they don't promise to
do "what you want" since what you want will really depend on the use
(there are a couple of special cases such as binary files where we try
to ensure meaningful thread-safety, because that's what users expect
from their experience with system APIs)
More information about the Python-ideas