Message289974
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). |
|
Date |
User |
Action |
Args |
2017-03-22 06:15:13 | serhiy.storchaka | set | recipients:
+ serhiy.storchaka, mark.dickinson, vstinner |
2017-03-22 06:15:11 | serhiy.storchaka | set | messageid: <1490163311.47.0.711325721357.issue29878@psf.upfronthosting.co.za> |
2017-03-22 06:15:11 | serhiy.storchaka | link | issue29878 messages |
2017-03-22 06:15:11 | serhiy.storchaka | create | |
|