On Sun, 2 Oct 2011 15:00:01 +0200
Victor Stinner <victor.stin...@haypocalc.com> wrote:
> 
> > I don't understand why StringIO couldn't simply be optimized a little
> > more, if it needs to.
> 
> Honestly, I didn't know that StringIO.write() is more efficient than 
> str+=str, 
> and it is surprising to use the io module (which is supposed to be related to 
> files) to manipulate strings.

StringIO is an in-memory file-like object, like in 2.x (where it lived
in the "cStringIO" module). I don't think it's a novel thing.

> The PEP 393 uses one memory block, you cannot resize a str object anymore.

I don't know why you're saying that. The concatenation optimization
worked in 2.x where the "str" type also used only one memory block. You
just have to check that the refcount is about to drop to zero.
Of course, resizing only works if the two unicode objects are of the
same "kind".

Regards

Antoine.


_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to