Ma Lin <malin...@163.com> added the comment:
Very sorry for update at the last moment. But after the update, we should no need to touch it in the future, so I think it's worthy. Please review the last commit in PR 21740, the previous commits have not been changed. IMO if use a Git client such as TortoiseGit, reviewing may be more convenient. The changes: 1, Move `Modules/blocks_output_buffer.h` to `Include/internal/pycore_blocks_output_buffer.h` Keep the `Modules` folder clean. 2, Ask the user to initialize the struct instance like this, and use assertions to check it: _BlocksOutputBuffer buffer = {.list = NULL}; Then no longer worry about whether buffer.list is uninitialized in error handling. There is an extra assignment, but it's beneficial to long-term code maintenance. 3, Change the type of BUFFER_BLOCK_SIZE from `int` to `Py_ssize_t`. The core code can remove a few type casts. 4, These functions return allocated size on success, return -1 on failure: _BlocksOutputBuffer_Init() _BlocksOutputBuffer_InitAndGrow() _BlocksOutputBuffer_InitWithSize() _BlocksOutputBuffer_Grow() If the code is used in other sites, this API is simpler. 5, All functions are decorated with `inline`. If the compiler is smart enough, it's possible to eliminate some code when `max_length` is constant and < 0. ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue41486> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com