StringIO proposal: add __iadd__

Paul Rubin http
Sun Jan 29 19:57:29 EST 2006


Paul Rubin <http://phr.cx@NOSPAM.invalid> writes:
> > After all, how do you think StringIO is implemented internally?  A list
> > of strings and a ''.join at the end are the best way that comes to mind,
> 
> I'd have used the array module.

I just checked the implementation and it uses ''.join combined with
some bogo-optimizations to cache the result of the join when you do a
seek or write.  That is, .seek can take linear time instead of
constant time, a pretty bogus situation if you ask me, though maybe
the amortized time isn't so bad over multiple calls.  I didn't check
how cStringIO does it.



More information about the Python-list mailing list