[Python-3000] Reimplementing TextIOWrapper in C?

Alexandre Vassalotti alexandre at peadrop.com
Fri Dec 28 20:37:10 CET 2007


As you all know now, I am working on a reimplementation of StringIO in
C (the Python version is just a BytesIO object in a TextIOWrapper). I
thought I was almost done, but it turns out that I need to reimplement
the whole newline translation mechanism in C. To do so, I will need to
modify almost every methods of StringIO just to make it handle
newlines properly -- basically reimplementing most of TextIOWrapper. I
realized it would be a better idea, to rewrite TextIOWrapper in C,
instead of StringIO. And then, add to it some special cases for
StringIO to avoid the encoding/decoding overheads.

Already wrote a good chunk of code for this -- i.e., I rewrote
IncrementalNewlineDecoder in C yesterday (turning 70 line of elegant
Python code into almost 300 lines of grotesque C). Anyway, I would
just like to know if some of you have hints or recommendations about
this.

Thanks,
-- Alexandre


More information about the Python-3000 mailing list