bpo-25433: Align bytearray strip methods to those found in byteobject.c#14771
bpo-25433: Align bytearray strip methods to those found in byteobject.c#14771rompe wants to merge 3 commits into
Conversation
The previous implementations differed a lot from the the ones found in bytesobject.c and all three of them included hardcoded lists of whitespace characters. Knowledge about whitespace already exists in pyctype.c and should not be duplicated.
|
Hello, and thanks for your contribution! I'm a bot set up to make sure that the project can legally accept your contribution by verifying you have signed the PSF contributor agreement (CLA). Our records indicate we have not received your CLA. For legal reasons we need you to sign this before we can look at your contribution. Please follow the steps outlined in the CPython devguide to rectify this issue. If you have recently signed the CLA, please wait at least one business day You can check yourself to see if the CLA has been received. Thanks again for your contribution, we look forward to reviewing it! |
|
I think that most of the code can be moved into |
|
This PR is stale because it has been open for 30 days with no activity. |
According to bpo-25433, knowledge about whitespace should be implemented only once.
bytearray.strip, .rstrip, .lstrip all had their own definitions of whitespace.
The implementations for
bytesis cleaner and a also a little bit faster, so I adopted the code from there and modified it to work with bytearrays and to fulfil the documentation which states that for bytearrays these functions always return copies, even if no changes have been applied.I checked for performance regressions:
Current master:
Using this branch:
Timings using custom byte sequences to strip showed no differences at all between the two branches, no matter if one or multiple characters long.
https://bugs.python.org/issue25433