4 ms·
I'm unable to reproduce. Increasing the number of iterations to `1000000` and using a temporary variable `c = counter + 1; counter = c` doesn't help either. Wh
by _ache_ 5y ago
I'm unable to reproduce. Increasing the number of iterations to `1000000` and using a temporary variable `c = counter + 1; counter = c` doesn't help either.
Why ? I'm on Linux, using Python 3.10. It's only happening using Python2.7.
- Aperocky 5y agoPython 2.x is unsupported and anyone using it should operate on the assumption that whatever bug its got is final unless they're the one who is going to fix it.
- verdagon 5y agoAuthor here, u/skeeto from https://www.reddit.com/r/programming/comments/sxy5q4/pythons_data_races_despite_the_global_interpreter/hxvaou0/?utm_source=reddit&utm_medium=web2x&context=3 https://www.reddit.com/r/programming/comments/sxy5q4/pythons... has some good insight into the 3.10 difference: > Ironically, CPython 3.10 has gone the opposite direction and made thread scheduling much more deterministic. It now only releases the GIL on backwards edges in the byte code The example in the article always prints 40000000 in CPython 3.10! I expect this will ultimately make Python code less reliable in the future as many programs will accidentally depend on this behavior.
- andreareina 5y agoDoes this mean loops/function call/return?
- rwbhn 5y agoYes. A comment in the referenced commit says "when returning from a call or on the back edges of loops."