Author vstinner
Recipients scoder, serhiy.storchaka, vstinner
Date 2016-08-24.12:11:37
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1472040701.62.0.862525052497.issue27848@psf.upfronthosting.co.za>
In-reply-to
Content
I recently added new functions to call functions in C, especially _PyObject_FastCallDict(). I started with the C int type for the number of positional arguments: "int nargs".

But slowly, when I started to patch code to use _PyObject_FastCallDict(), I used more and more Py_ssize_t variables for the number of arguments, variable downcasted to int to call _PyObject_FastCallDict().

It is similar to the old issue #18295.

I propose to avoid any risk of integer overflow by using Py_ssize_t everywhere. It *might* produce more efficient machine code, since "i++" may require extra code to handle overflow when the int rather is used. But I'm not sure that Py_ssize_t is better, especially when -fwrapv option of the GCC compiler is used.

Attached patch implements this idea.

The patch also uses Py_ssize_t for some BUILD_xxx opcodes like BUILD_LIST_UNPACK. The change is not directly related. I wrote it in the hope that machine code could be more efficient, and avoid having to ask myself if types could overflow or not.
History
Date User Action Args
2016-08-24 12:11:43vstinnersetrecipients: + vstinner, scoder, serhiy.storchaka
2016-08-24 12:11:41vstinnersetmessageid: <1472040701.62.0.862525052497.issue27848@psf.upfronthosting.co.za>
2016-08-24 12:11:41vstinnerlinkissue27848 messages
2016-08-24 12:11:41vstinnercreate