File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -10,6 +10,8 @@ Projected release date: 2013-11-24
1010Core and Builtins
1111-----------------
1212
13+ - Issue #19369: Optimized the usage of __length_hint__().
14+
1315- Issue #18603: Ensure that PyOS_mystricmp and PyOS_mystrnicmp are in the
1416 Python executable and not removed by the linker's optimizer.
1517
Original file line number Diff line number Diff line change @@ -82,15 +82,17 @@ PyObject_LengthHint(PyObject *o, Py_ssize_t defaultvalue)
8282 PyObject * hint , * result ;
8383 Py_ssize_t res ;
8484 _Py_IDENTIFIER (__length_hint__ );
85- res = PyObject_Length (o );
86- if (res < 0 && PyErr_Occurred ()) {
87- if (!PyErr_ExceptionMatches (PyExc_TypeError )) {
88- return -1 ;
85+ if (_PyObject_HasLen (o )) {
86+ res = PyObject_Length (o );
87+ if (res < 0 && PyErr_Occurred ()) {
88+ if (!PyErr_ExceptionMatches (PyExc_TypeError )) {
89+ return -1 ;
90+ }
91+ PyErr_Clear ();
92+ }
93+ else {
94+ return res ;
8995 }
90- PyErr_Clear ();
91- }
92- else {
93- return res ;
9496 }
9597 hint = _PyObject_LookupSpecial (o , & PyId___length_hint__ );
9698 if (hint == NULL ) {
You can’t perform that action at this time.
0 commit comments