[Python-3000] Reimplementing TextIOWrapper in C?
Brett Cannon
brett at python.org
Fri Dec 28 20:47:08 CET 2007
On Dec 28, 2007 11:37 AM, Alexandre Vassalotti <alexandre at peadrop.com> wrote:
> 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.
>
No specific hints, but why do you feel you must implement the whole
thing in C? Can't you just import 'io' in your StringIO code and make
calls into the Python code?
-Brett
More information about the Python-3000
mailing list