This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author serhiy.storchaka
Recipients mark.dickinson, serhiy.storchaka, vstinner
Date 2017-03-22.06:15:06
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1490163311.47.0.711325721357.issue29878@psf.upfronthosting.co.za>
In-reply-to
Content
When C code needs to compare Python object with int 0 or add int 1 it either use local reference to PyLong_FromLong(0) and PyLong_FromLong(1) which should be decrefed just after use or module level global variable initialized and cleared during initializing and finalizing the module.

Proposed patch adds global variables _PyLong_Zero and _PyLong_One for references to integer objects 0 and 1. This simplifies the code since no need to initialize local variables, check for error the result of PyLong_FromLong() and decref it after use. The patch decreases the total code size by 244 lines.

That variables are only for internal use. User code should use PyLong_FromLong(0) and PyLong_FromLong(1).
History
Date User Action Args
2017-03-22 06:15:13serhiy.storchakasetrecipients: + serhiy.storchaka, mark.dickinson, vstinner
2017-03-22 06:15:11serhiy.storchakasetmessageid: <1490163311.47.0.711325721357.issue29878@psf.upfronthosting.co.za>
2017-03-22 06:15:11serhiy.storchakalinkissue29878 messages
2017-03-22 06:15:11serhiy.storchakacreate