Ulf Rompe <u...@rompe.org> added the comment:

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.

----------
nosy: +rompe

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue25433>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to