<arigo_>
fijal: (Py_ssize_t)refcount is really just refcount, which is a signed number already I think
<arigo_>
the only risk I see is that a compiler will replace "if (refcount >= 0) refcount++;" with "refcount += (refcount >= 0);", which would defeat the original purpose, which is to not write to refcount at all if it is < 0
<arigo_>
but I'm not sure it's a valid C change
<arigo_>
it seems not, but you never know, of course
<arigo_>
so no risk
<nimaje>
hm, I don't think the C standard considers writing the same value to non-volatile variables a side effect, so that replacement would be ok, as it is '+= 0' for the case when no writing takes place in the original, but I would have to look that up to be sure
<arigo_>
stackoverflow says no, the C compiler is not allowed to write if the source code doesn't contain the write, for two reasons: 1. it could trigger a segfault if the memory is read-only; 2. in multithreaded programs it's wrong because it adds a data race
<arigo_>
in this case, we don't want a write so that the page is not marked as dirty, which is almost the same as reason 1.
<arigo_>
you could write a C extension module with static global Python objects in read-only memory, and that would work in 3.12
arigo_ is now known as arigato
arigato is now known as arigo_
<cfbolz>
arigo_: which I think is one of the motivations for the whole immortal object idea, isn't it?