Message347853
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. |
|
Date |
User |
Action |
Args |
2019-07-13 18:38:27 | rompe | set | recipients:
+ rompe, jwilk, ezio.melotti, docs@python, Dimitri Papadopoulos Orfanos, nitishch, joel.johnson, oulenz, edmundselliot@gmail.com |
2019-07-13 18:38:27 | rompe | set | messageid: <1563043107.74.0.50935545081.issue25433@roundup.psfhosted.org> |
2019-07-13 18:38:27 | rompe | link | issue25433 messages |
2019-07-13 18:38:27 | rompe | create | |
|