gh-129813, PEP 782: Use PyBytesWriter in _ssl#138929
Conversation
Replace PyBytes_FromStringAndSize(NULL, size) and _PyBytes_Resize() with the new public PyBytesWriter API.
|
This is a performance critical function, please check that this has no slowdown on microbenchmark. |
Do you have advises on how to write such benchmark? Benchmarks on similar functions:
Creating a writer takes less than 30 ns, so time is dominated by I/O operations. |
|
I wrote a similar change to use |
|
I am not worried about performance on this change. The more modern code (1) has the same complexity as the older code and (2) the CPU performance should already be dominated by the decryption that happens to generate the data being read in the first place - not our potential data copy if an internal resize were to move something. |
|
Merged, thanks for reviews. |
Replace PyBytes_FromStringAndSize(NULL, size) and _PyBytes_Resize() with the new public PyBytesWriter API.