File tree Expand file tree Collapse file tree 1 file changed +14
-6
lines changed
Expand file tree Collapse file tree 1 file changed +14
-6
lines changed Original file line number Diff line number Diff line change 77#include "pycore_modsupport.h" // _PyArg_NoKwnames()
88#include "pycore_range.h"
99#include "pycore_tuple.h" // _PyTuple_ITEMS()
10+ #include "pycore_pyatomic_ft_wrappers.h"
1011
1112
1213/* Support objects whose length is > PY_SSIZE_T_MAX.
@@ -813,24 +814,31 @@ PyTypeObject PyRange_Type = {
813814 in the normal case, but possible for any numeric value.
814815*/
815816
816-
817- #include "pycore_pyatomic_ft_wrappers.h"
818-
819817static PyObject *
820818rangeiter_next (_PyRangeIterObject * r )
821819{
820+ #ifdef Py_GIL_DISABLED
821+ uint64_t step = _Py_atomic_load_int64_relaxed (& r -> step );
822822 do {
823- long len = _Py_atomic_load_int64_relaxed (& r -> len );
823+ uint64_t len = _Py_atomic_load_int64_relaxed (& r -> len );
824824 if (len <= 0 ) {
825825 return NULL ;
826826 }
827- long result = _Py_atomic_load_int64_relaxed (& r -> start );
828- long step = _Py_atomic_load_int64_relaxed (& r -> step );
827+ uint64_t result = _Py_atomic_load_int64_relaxed (& r -> start );
829828 if (_Py_atomic_compare_exchange_int64 (& r -> start , & result , result + step )) {
830829 _Py_atomic_add_int64 (& r -> len , -1 );
831830 return PyLong_FromLong (result );
832831 }
833832 } while (1 );
833+ #else
834+ if (r -> len > 0 ) {
835+ long result = r -> start ;
836+ r -> start = result + r -> step ;
837+ r -> len -- ;
838+ return PyLong_FromLong (result );
839+ }
840+ return NULL ;
841+ #endif
834842}
835843
836844static PyObject *
You can’t perform that action at this time.
0 commit comments