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 rompe
Recipients Dimitri Papadopoulos Orfanos, docs@python, edmundselliot@gmail.com, ezio.melotti, joel.johnson, jwilk, nitishch, oulenz, rompe
Date 2019-07-13.18:38:27
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1563043107.74.0.50935545081.issue25433@roundup.psfhosted.org>
In-reply-to
Content
Using a re.sub() call as documentation:

1. wouldn't be helpful for many developers. If they need to look up the documentation of a simple method they shouldn't be forced to learn about a more complex one as well to understand it.
2. would be wild guessing since the re module defines its own whitespace as well.

I have created a pull request that aligns the strip methods of bytearray to those of bytes objects. The implementation found there is cleaner and even a little bit faster.

Current master:

./python -m timeit -s 'bla = bytearray(b"  foo  ")' 'bla.lstrip()'
1000000 loops, best of 5: 245 nsec per loop
./python -m timeit -s 'bla = bytearray(b"  foo  ")' 'bla.rstrip()'
1000000 loops, best of 5: 245 nsec per loop
./python -m timeit -s 'bla = bytearray(b"  foo  ")' 'bla.strip()'
1000000 loops, best of 5: 260 nsec per loop

Using my patch:

./python -m timeit -s 'bla = bytearray(b"  foo  ")' 'bla.lstrip()'
1000000 loops, best of 5: 235 nsec per loop
./python -m timeit -s 'bla = bytearray(b"  foo  ")' 'bla.rstrip()'
1000000 loops, best of 5: 235 nsec per loop
./python -m timeit -s 'bla = bytearray(b"  foo  ")' 'bla.strip()'
1000000 loops, best of 5: 239 nsec per loop


I have also updated the documentation, adding "whitespace" to the glossary and linking to it from many places in the documentation of standard types.
History
Date User Action Args
2019-07-13 18:38:27rompesetrecipients: + rompe, jwilk, ezio.melotti, docs@python, Dimitri Papadopoulos Orfanos, nitishch, joel.johnson, oulenz, edmundselliot@gmail.com
2019-07-13 18:38:27rompesetmessageid: <1563043107.74.0.50935545081.issue25433@roundup.psfhosted.org>
2019-07-13 18:38:27rompelinkissue25433 messages
2019-07-13 18:38:27rompecreate