Look free ID genertion (was: Is there a more efficient threading lock?)

Dieter Maurer dieter at handshake.de
Wed Mar 1 13:43:06 EST 2023


Chris Angelico wrote at 2023-3-1 12:58 +1100:
> ...
> The
>atomicity would be more useful in that context as it would give
>lock-free ID generation, which doesn't work in Python.

I have seen `itertools.count` for that.
This works because its `__next__` is implemented in "C" and
therefore will not be interrupted by a thread switch.


More information about the Python-list mailing list