[pypy-dev] How will STM actually integrate with normal Python code

Timothy Baldridge tbaldridge at gmail.com
Tue Jan 31 16:26:46 CET 2012


As Armin stated in a recent mailing list thread:

"In PyPy, we look at STM like we would look at the GC.  It may be
replaced in a week by a different one, but for the "end user" writing
pure Python code, it essentially doesn't make a difference.  "

So, my question is, how exactly will STM integrate into PyPy? I'm
going to take a guess here, and perhaps someone can elaborate to
correct me.

>From what I'm reading, PyPy with STM will offer the same promises (or
lack of promises) that the JVM and CLR offer their code:

For example, this code:

def foo(d):
    if "foo" in d:
        del d["foo"]

Will never cause a segmentation fault (due to multiple threads
accessing "d" at the same time), but it may throw a KeyError. That is,
all Python code will continue to be "thread-safe" as it is in CPython,
but race conditions will continue to exist and must be handled in
standard ways (locks, CAS, etc.).

Am I right in this description?

Thanks,

Timothy

-- 
“One of the main causes of the fall of the Roman Empire was
that–lacking zero–they had no way to indicate successful termination
of their C programs.”
(Robert Firth)


More information about the pypy-dev mailing list