3 ms·
Could you? What enforces only a single thread having access to a given reference? What about global variables?
by smaddox 3y ago
Could you? What enforces only a single thread having access to a given reference? What about global variables?
- insanitybit 3y agoIf there's a refcount of 1 you can mutate the value safely because no other thread could be trying to read/ write to it. And the only thread that can give it to others would be the one that's doing that mutation, so it can't suddenly change. I'd assume that importing any sort of module level variable would imply an increment of the counter, but unsure.