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 malin
Recipients gregory.p.smith, malin, methane
Date 2021-04-26.11:54:31
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1619438071.89.0.571938783785.issue41486@roundup.psfhosted.org>
In-reply-to
Content
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.
History
Date User Action Args
2021-04-26 11:54:31malinsetrecipients: + malin, gregory.p.smith, methane
2021-04-26 11:54:31malinsetmessageid: <1619438071.89.0.571938783785.issue41486@roundup.psfhosted.org>
2021-04-26 11:54:31malinlinkissue41486 messages
2021-04-26 11:54:31malincreate