Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Compare and swap instruction in python

Is it possible to have a CAS instruction in python? CAS = compare and swap.

I'm looking for something equivalent for expression in C++:

std::atomic<T> a;
a.compare_exchange_strong(x, y);
like image 955
Gilgamesz Avatar asked Mar 03 '26 10:03

Gilgamesz


1 Answers

Python doesn't have CAS operation. As you know CAS is an atomic instruction used in multithreading to achieve synchronization. C++ has a much more sophisticated multithreading and synchronization than Python.

like image 132
E Gary Avatar answered Mar 06 '26 00:03

E Gary



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!