Serhiy Storchaka added the comment: 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. ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue29878> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com