Stefan Behnel added the comment:

Patch and test look correct. They fix a bug that produces incorrect output, so 
I vote for backporting them. Most code won't see the difference as whitespace 
control characters are rare in attribute values. And code that uses them will 
benefit from correctness. Obviously, there might also be breakage in the rare 
case that code puts control characters into attribute values and expects them 
to disappear magically, but then it's the user code that is wrong here.

Only issue is that serialisation is slow already and this change slows it down 
a bit more. Every attribute value will now be searched 8 times instead of 5 
times. I added a minor review comment that would normally reduce it to 7. 
timeit suggests to me that the overall overhead is still tiny, though, and thus 
acceptable:

$ python3.5 -m timeit -s "s = 'askhfalsdhfashldfsadf'" "'\n' in s"
10000000 loops, best of 3: 0.0383 usec per loop

$ python3.5 -m timeit -s "s = 'askhfalsdhfashldfsadf'" "s.replace('\n', 'y')"
10000000 loops, best of 3: 0.151 usec per loop

$ python3.5 -m timeit -s "s = 'askhfalsdhfashldfsadf'; rep=s.replace" 
"rep('\n', 'y')"
10000000 loops, best of 3: 0.12 usec per loop

----------

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

Reply via email to