Message290005
Yet one idea that can make the code simpler is make PyLong_FromLong(0) and PyLong_FromLong(1) never failing. I.e. require NSMALLPOSINTS not less than 2.
> Also consider adding new function PyLong_Increment. This basic operation is small pain using the current API. It may also give a small speed benefit.
Smaller pain with using _PyLong_One and Py_SETREF().
Py_SETREF(long_obj, PyNumber_Add(long_obj, _PyLong_One));
Agree that with _PyLong_Increment() it can look better and be faster. But I don't know whether incrementing by 1 is enough popular operation. I have counted 5 cases in the stdlib (not counting tests): for enumerate, range and Counter.
> The problem is to make sure that singletons are created in the right order :-/
Yes, I spent much time for making empty Unicode string singleton always be initialized. It can be accessed at very early stage. |
|
Date |
User |
Action |
Args |
2017-03-22 18:02:43 | serhiy.storchaka | set | recipients:
+ serhiy.storchaka, rhettinger, mark.dickinson, vstinner |
2017-03-22 18:02:43 | serhiy.storchaka | set | messageid: <1490205763.83.0.955529502208.issue29878@psf.upfronthosting.co.za> |
2017-03-22 18:02:43 | serhiy.storchaka | link | issue29878 messages |
2017-03-22 18:02:43 | serhiy.storchaka | create | |
|