Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Explicitely convert bytes to str. Works in both Python 2 and 3, Fixes… #204
The second commit, titled "Improve performance of carriage return replacement." was not meant to be in the same Pull Request, which is why it's not documented. My poor git skills betrayed me. Here is the explanation.
String manipulation with Python's
A brief look at this specific example (carriage return replacement) can be found here, and for completeness:
In : timeit 'Apples\r\nOranges\r\nKiwis\rGrapes\r'.replace('\r\n', '\n').replace('\r', '\n') 1000000 loops, best of 3: 404 ns per loop In : import re In : timeit re.sub(r'\r\n|\r', '\n', 'Apples\r\nOranges\r\nKiwis\rGrapes\r') 100000 loops, best of 3: 2.03 µs per loop