io.TextIOWrapper.tell() is unusably slow in Python 2.7. This same problem was introduced in Python 3 and fixed in Python 3.3 (see Issue # 11114). Any chance of getting the fix backported into the Python 2.7 library? It would make it much easier to modernize Unicode handling in libraries that have to support both 2 and 3 using the same codebase.
I suggest that you try backporting the patch to 2.7 and and/or ask on #11114 whether there was a positive reason not to do so (and mention that you opened this issue to do so).
From the original report: > This problem did not exist in version 2.7.1 [...] We usually don't treat performance improvements as bug fixes unless it was introduced in a bug fix release (or it needs to be explicitly approved by the BDFL or the 2.7 release manager) If TextIOWrapper.tell() performance got worse after 2.7.1, there might be a chance to backport issue 11114 to 2.7. Adding Antoine (author of the patch) and Benjamin (2.7. release manager) to get their opinion.
The original patch is quite delicate and I'm not comfortable backporting to 2.7. This is why it was pushed to 3.3 but not backported to 3.2.x (AFAIR). 2.7 has existed with this issue for years, now, and is slowly nearing end-of-life. I'll let Benjamin make the final decision.
Berker Peksag, Antoine Pitrou (who implemented the discussed change) and me are opposed to backporting this optimization, so I close the issue as WONTFIX. The only known workaround is to upgrade to Python 3, sorry! Benjamin: Please speakup if you want this optimization in the next Python 2.7 release ;-) > The original patch is quite delicate and I'm not comfortable backporting to 2.7. Oh, the "byte/character ratio" "hack"... I'm not confortable with this one neither, even if it seems like it works on Python 3 (I didn't recall any bug report related to this).