File tree 2 files changed +21
-10
lines changed 2 files changed +21
-10
lines changed Original file line number Diff line number Diff line change @@ -29,7 +29,11 @@ typedef struct {
29
29
30
30
static inline Py_ssize_t PyList_GET_SIZE (PyObject * op ) {
31
31
PyListObject * list = _PyList_CAST (op );
32
+ #ifdef Py_GIL_DISABLED
33
+ return _Py_atomic_load_ssize_relaxed (& (_PyVarObject_CAST (list )-> ob_size ));
34
+ #else
32
35
return Py_SIZE (list );
36
+ #endif
33
37
}
34
38
#define PyList_GET_SIZE (op ) PyList_GET_SIZE(_PyObject_CAST(op))
35
39
Original file line number Diff line number Diff line change @@ -383,18 +383,11 @@ list_dealloc(PyObject *self)
383
383
}
384
384
385
385
static PyObject *
386
- list_repr ( PyObject * self )
386
+ list_repr_impl ( PyListObject * v )
387
387
{
388
- PyListObject * v = (PyListObject * )self ;
389
- Py_ssize_t i ;
390
388
PyObject * s ;
391
389
_PyUnicodeWriter writer ;
392
-
393
- if (Py_SIZE (v ) == 0 ) {
394
- return PyUnicode_FromString ("[]" );
395
- }
396
-
397
- i = Py_ReprEnter ((PyObject * )v );
390
+ Py_ssize_t i = Py_ReprEnter ((PyObject * )v );
398
391
if (i != 0 ) {
399
392
return i > 0 ? PyUnicode_FromString ("[...]" ) : NULL ;
400
393
}
@@ -439,10 +432,24 @@ list_repr(PyObject *self)
439
432
return NULL ;
440
433
}
441
434
435
+ static PyObject *
436
+ list_repr (PyObject * self )
437
+ {
438
+ if (PyList_GET_SIZE (self ) == 0 ) {
439
+ return PyUnicode_FromString ("[]" );
440
+ }
441
+ PyListObject * v = (PyListObject * )self ;
442
+ PyObject * ret = NULL ;
443
+ Py_BEGIN_CRITICAL_SECTION (v );
444
+ ret = list_repr_impl (v );
445
+ Py_END_CRITICAL_SECTION ();
446
+ return ret ;
447
+ }
448
+
442
449
static Py_ssize_t
443
450
list_length (PyObject * a )
444
451
{
445
- return Py_SIZE (a );
452
+ return PyList_GET_SIZE (a );
446
453
}
447
454
448
455
static int
You can’t perform that action at this time.
0 commit comments