A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2006-November/069983.html below:

[Python-Dev] PyFAQ: thread-safe interpreter operations

[Python-Dev] PyFAQ: thread-safe interpreter operations"Martin v. Löwis" martin at v.loewis.de
Mon Nov 20 23:55:42 CET 2006
Fredrik Lundh schrieb:
> the FAQ contains a list of "atomic" operation, and someone recently 
> asked whether += belongs to this group.

In general, += isn't atomic: it may invoke __add__ or __iadd__ on the
left-hand side, or __radd__ on the right-hand side.

>From your list, I agree with Josiah Carlson's observation that the
examples you give involve separate name lookups (e.g. L.append(x)
loads L, then fetches L.append, then loads x, then calls apped,
each in a single opcode); the actual operation is atomic.

If you only look at the actual operation, the these aren't atomic:

x.field = y # may invoke __setattr__, may also be a property
D[x] = y    # may invoke x.__hash__, and x.__eq__

I'm uncertain whether D1.update(D2) will invoke callbacks (it
probably will).

Regards,
Martin
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4