@@ -9,10 +9,11 @@ which was written by Kevin O'Connor, augmented by Tim Peters,
99#include "Python.h"
1010
1111static int
12- _siftdown (PyListObject * heap , int startpos , int pos )
12+ _siftdown (PyListObject * heap , Py_ssize_t startpos , Py_ssize_t pos )
1313{
1414 PyObject * newitem , * parent ;
15- int cmp , parentpos ;
15+ int cmp ;
16+ Py_ssize_t parentpos ;
1617
1718 assert (PyList_Check (heap ));
1819 if (pos >= PyList_GET_SIZE (heap )) {
@@ -45,9 +46,9 @@ _siftdown(PyListObject *heap, int startpos, int pos)
4546}
4647
4748static int
48- _siftup (PyListObject * heap , int pos )
49+ _siftup (PyListObject * heap , Py_ssize_t pos )
4950{
50- int startpos , endpos , childpos , rightpos ;
51+ Py_ssize_t startpos , endpos , childpos , rightpos ;
5152 int cmp ;
5253 PyObject * newitem , * tmp ;
5354
@@ -123,7 +124,7 @@ static PyObject *
123124heappop (PyObject * self , PyObject * heap )
124125{
125126 PyObject * lastelt , * returnitem ;
126- int n ;
127+ Py_ssize_t n ;
127128
128129 if (!PyList_Check (heap )) {
129130 PyErr_SetString (PyExc_TypeError , "heap argument must be a list" );
@@ -197,7 +198,7 @@ this routine unless written as part of a conditional replacement:\n\n\
197198static PyObject *
198199heapify (PyObject * self , PyObject * heap )
199200{
200- int i , n ;
201+ Py_ssize_t i , n ;
201202
202203 if (!PyList_Check (heap )) {
203204 PyErr_SetString (PyExc_TypeError , "heap argument must be a list" );
@@ -300,10 +301,11 @@ PyDoc_STRVAR(nlargest_doc,
300301Equivalent to: sorted(iterable, reverse=True)[:n]\n" );
301302
302303static int
303- _siftdownmax (PyListObject * heap , int startpos , int pos )
304+ _siftdownmax (PyListObject * heap , Py_ssize_t startpos , Py_ssize_t pos )
304305{
305306 PyObject * newitem , * parent ;
306- int cmp , parentpos ;
307+ int cmp ;
308+ Py_ssize_t parentpos ;
307309
308310 assert (PyList_Check (heap ));
309311 if (pos >= PyList_GET_SIZE (heap )) {
@@ -336,9 +338,9 @@ _siftdownmax(PyListObject *heap, int startpos, int pos)
336338}
337339
338340static int
339- _siftupmax (PyListObject * heap , int pos )
341+ _siftupmax (PyListObject * heap , Py_ssize_t pos )
340342{
341- int startpos , endpos , childpos , rightpos ;
343+ Py_ssize_t startpos , endpos , childpos , rightpos ;
342344 int cmp ;
343345 PyObject * newitem , * tmp ;
344346
@@ -389,7 +391,7 @@ static PyObject *
389391nsmallest (PyObject * self , PyObject * args )
390392{
391393 PyObject * heap = NULL , * elem , * iterable , * los , * it , * oldelem ;
392- int i , n ;
394+ Py_ssize_t i , n ;
393395
394396 if (!PyArg_ParseTuple (args , "iO:nsmallest" , & n , & iterable ))
395397 return NULL ;
0 commit comments