[Python-ideas] thread safe dictionary initialisation from mappings: dict(non_dict_mapping)

Chris Jerdonek chris.jerdonek at gmail.com
Tue Nov 20 20:56:41 CET 2012


On Tue, Nov 20, 2012 at 10:30 AM, Antoine Pitrou <solipsis at pitrou.net> wrote:
> On Tue, 20 Nov 2012 10:33:53 +0100
> Anselm Kruis
> <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
> case.

There is an open documentation issue related to this here:

http://bugs.python.org/issue15339

--Chris



More information about the Python-ideas mailing list