Archive for November, 2011
The most disturbing change from Python 2 to 3 definitely is not the
print() function; nor that some functions which used to return lists now return iterators; nor the removal of
__cmp__; but the transition to Unicode.
I’m completely supportive of the transition per se, but I’m disappointed that they’re trying to compel us to use Unicode by dropping useful functionalities for byte-streams/8-byte strings. For example,
bytes has no
% in Python 3.
I have some code like this:
proc = subprocess.Popen((....), stdout=subprocess.PIPE) for line in proc.stdout: ...
I found that, on Linux, this code snippet is almost 10 times slower in Python 3 than in Python 2. Then I strace‘d the code and found Python 3 is passing length 1 to
read, incurring thousands of times more system calls than Python 2. Are you kidding me? I was forced to use something like
I understand this is not the direct result of the transition to Unicode, but it is somehow related.